GithubHelp home page GithubHelp logo

edn's People

Contributors

dreid avatar jml avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jml

edn's Issues

Character type?

At the moment, there's no Character type, which means that characters parsed by edn cannot be reliably unparsed as characters, as there's no way to distinguish a single-element string from a character in Python.

I don't know if this is such a bad thing.

Add Jonathan Lange to owners in LICENSE

I think it would be fair if I were listed as a joint copyright holder.

No accompanying patch, because I don't want to publish a version which has incorrect LICENSE information.

Pretty printer

We currently have a very basic formatter / printer / unparser (we really must settle on a term), but no pretty printer. Everyone loves a pretty printer. We should have one.

Suggestion: keyworddict

Not 100% sure this is a good idea, but here we go.

The natural way to use maps in Clojure is to use keywords for the keys. In Python, the natural way is to use strings for keys. When writing Python code that works with Clojure code via edn, it becomes tedious to make dicts with Keywords as keys.

So, perhaps it's worth adding a convenience class which is a dict where all of the keys are keywords, but can be accessed & updated using string syntax, but are stored internally as keywords.

These examples are meant to be illustrative, not prescriptive.

>>> x = keyworddict()
>>> x.with_pair('foo', 'bar')
>>> repr(x)
{Keyword(Symbol('foo')): 'bar'}
>>> x['foo']
'bar'
>>> dumps(x)
{:foo "bar"}
>>> x.with_pair(42, 'qux')
Traceback (most recent call last):
  ...
ValueError: Invalid keyword: 42

And also,

>>> x = keyworddict(prefix="myproject")
>>> x.with_pair('foo', 'bar')
>>> repr(x)
{Keyword(Symbol('foo', 'myproject')): 'bar'}
>>> x['foo']
'bar'
>>> dumps(x)
{:myproject/foo "bar"}

{} (frozendict) doesn't work as a TaggedValue

recording for posterity.

...............E.........................................................................................
======================================================================
ERROR: test_tag (edn.tests.test_ast.EDNTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/callen/code/edn/edn/tests/test_ast.py", line 179, in test_tag
    ('#foo {}', TaggedValue(Symbol('foo'), frozendict({})))
  File "/Users/callen/.virtualenv/sweden/lib/python2.7/site-packages/Parsley-1.2-py2.7.egg/terml/nodes.py", line 144, in mkterm
    tuple([coerceToTerm(a) for a in args]),
  File "/Users/callen/.virtualenv/sweden/lib/python2.7/site-packages/Parsley-1.2-py2.7.egg/terml/nodes.py", line 138, in coerceToTerm
    raise ValueError("Could not coerce %r to Term" % (val,))
ValueError: Could not coerce frozendict({}) to Term

----------------------------------------------------------------------
Ran 105 tests in 0.181s

FAILED (errors=1)

If I get a workable fix together, I'll PR it with my test(s).

Stream support

Currently there's no support for loading edn data that contains multiple elements.

Relatedly, there's no support for taking a stream as input and parsing it incrementally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.