Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master #4

Merged
merged 74 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2f2c713
Convert requirements from exact to minimum
swaroopch Oct 8, 2017
ec3239f
Bump version to 0.5.13
swaroopch Oct 8, 2017
c670ff2
LICENSE: bump year
bfontaine Aug 2, 2018
6d1a0ba
Fix ambiguous variable name (#44)
bfontaine Aug 4, 2018
aab186e
Add a Changelog
bfontaine Aug 4, 2018
bf69bb3
Fix parsing of exact-precision floats with a negative exposant (#47)
bfontaine Aug 5, 2018
ec2c10e
Accept missing printable ASCII chars (#45)
bfontaine Aug 5, 2018
ea068bd
Add a sort_sets optional keyword argument to dump (#42)
bfontaine Aug 16, 2018
b71fd3b
fix latin
konr May 10, 2017
7cb0c3f
add failing unit test
konr May 10, 2017
faf098e
add ImmutableList
konr May 10, 2017
55793ce
use ImmutableList on code
konr May 10, 2017
7b7aef3
conform to flake8
konr May 16, 2017
4de3130
add test
konr May 23, 2017
2f0632e
add placeholder file
konr May 23, 2017
294c7f7
workaround for limitation on the image downstream
konr May 23, 2017
3779ef7
remove conda.txt file
konr Aug 23, 2018
0a45a22
add docstring
konr Aug 23, 2018
c86cf6f
descend from Sequence instead of MutableSequence
konr Aug 23, 2018
4d4cd74
copy explicitly
konr Aug 23, 2018
88a0078
remove MutableSequence tests
konr Aug 23, 2018
bc88cf3
bump version
konr Aug 23, 2018
a93d33d
fix formatting
konr Aug 23, 2018
dd3cdeb
use copy.copy()
konr Aug 23, 2018
db832f6
remove redundant tests
konr Aug 24, 2018
356e4a6
simplify condition
konr Aug 24, 2018
2d84843
Raise custom exceptions on syntax errors (#46)
bfontaine Aug 24, 2018
f53f98d
Add CONTRIBUTING.md (#48)
bfontaine Aug 24, 2018
a22a7f5
Merge branch 'master' into master
swaroopch Aug 24, 2018
7a3865c
Merge pull request #50 from konr/master
swaroopch Aug 24, 2018
a6e974d
Handle fractions
bfontaine Aug 26, 2018
f5096dc
Handle #_
bfontaine Aug 3, 2018
fde947a
Add tests for #_
bfontaine Aug 26, 2018
9919a7a
Merge pull request #43 from bfontaine/discard
swaroopch Sep 7, 2018
a91ad8a
Merge pull request #49 from bfontaine/feature/fractions
swaroopch Sep 7, 2018
6740ed8
Tweak README regarding caveats + mention @bfontaine contributor
swaroopch Sep 7, 2018
b721edd
Bump version to 0.6.0
swaroopch Sep 7, 2018
629b52d
Add v0.6.0 to the Changelog
bfontaine Sep 9, 2018
0dfb8bc
Run Travis tests on latest Python 3.7
swaroopch Sep 19, 2018
22e16bd
Use dist: xenial
swaroopch Sep 19, 2018
9bc28f6
Merge pull request #51 from swaroopch/travis_py37
swaroopch Sep 19, 2018
841a479
Use mutable data structures to improve parsing time
czan Sep 20, 2018
8738f15
Merge pull request #52 from czan/master
swaroopch Sep 21, 2018
32c124b
Bump version to 0.6.1
swaroopch Sep 21, 2018
c14529e
Update setup.py to 0.6.1
swaroopch Sep 21, 2018
f6e260c
Various code simplifications (#53)
bfontaine Sep 27, 2018
9905734
Parse nil and booleans as symbols (#54)
bfontaine Sep 27, 2018
ed68fce
Add Vagrantfile for local dev
swaroopch Jan 4, 2019
c9aa665
Use collections.abc instead of collections
swaroopch Jan 4, 2019
67d0f15
Fix build issues
swaroopch Jan 4, 2019
a1ca4d8
Fix Python 2.x compatibility
swaroopch Jan 4, 2019
3a84231
Bump version to 0.6.2
swaroopch Jan 4, 2019
38c5eae
DRY the requirements
swaroopch Jan 4, 2019
8a4469a
Add badge for PyPI version
swaroopch Jan 14, 2019
fb54e2c
add support for unicode char literals
LeXofLeviafan Mar 25, 2019
8430324
fixed indentation in test_sort_keys
LeXofLeviafan Mar 25, 2019
a83e61d
combined version_info checks in edn_format/edn_lex.py
swaroopch Apr 3, 2019
1a66852
fixed comment in char token definition
LeXofLeviafan Apr 3, 2019
434a8e8
made changes according to flake8 demands
LeXofLeviafan Apr 3, 2019
e179aa4
Merge pull request #56 from LeXofLeviafan/master
swaroopch Apr 16, 2019
258fa17
Bump version to 0.6.3
swaroopch Apr 16, 2019
8878b35
Travis : Upgrade Ubuntu version to latest LTS, bionic
swaroopch Apr 16, 2019
bba3ba1
Merge pull request #57 from swaroopch/travis-upgrade-ubuntu
swaroopch Apr 16, 2019
727105f
Use tag signing
swaroopch Jun 24, 2019
3ac726e
Add an edn_parse.tag decorator, + docs and tests on tags (#59)
bfontaine Sep 14, 2019
969f062
Contributor Notes: replace the deprecated commands
bfontaine Sep 14, 2019
a885ee5
Version 0.6.4
bfontaine Sep 14, 2019
bd49d44
Move contributor notes in CONTRIBUTING.md (#61)
bfontaine Oct 2, 2019
0d4c213
Add edn_format.loads_all to parse all expressions in a string (#60)
bfontaine Oct 2, 2019
9199f9b
Disallow 0-prefixed integers
bfontaine Nov 1, 2019
eba8686
Parse hexadecimal notation
bfontaine Nov 1, 2019
09add5d
Release v0.6.5
bfontaine Nov 3, 2019
678d48f
Merge branch 'master' of https://github.com/swaroopch/edn_format into…
gabrielferreira95 Nov 22, 2019
7dd6a13
Bump version to 0.6.5-nu
gabrielferreira95 Nov 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dist
edn_format.egg-info/
*_flymake.py
venv
build
build
.vagrant
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
dist: bionic # latest LTS as per https://wiki.ubuntu.com/Releases
language: python
python:
- "2.7"
- "3.6"
- "3.7"
install:
- "pip install -r requirements.txt"
- "pip install flake8"
Expand Down
112 changes: 112 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# `edn_format` Changelog

## v0.6.5 (2019/11/03)

* Parse integers in hexadecimal notation
* Disallow `0`-prefixed integers other than zero itself

## v0.6.4 (2019/09/14)

* Add an `edn_parse.tag` decorator

## v0.6.3 (2019/04/16)

* Add support for Unicode char literals

## v0.6.2 (2019/01/04)

* Parse `nil` and booleans as symbols

## v0.6.1 (2018/09/21)

* Use mutable data structures to improve parsing time
* Run Travis tests on Python 3.7

## v0.6.0 (2018/09/08)

* Fix vector parser to use `ImmutableList`
* Fix parsing of exact-precision floats with a negative exposant
* Support all ASCII characters
* Add a `sort_sets` optional argument to `dumps`
* Raise custom exceptions on syntax errors
* Support fractions
* Support `#_`

## v0.5.13 (2017/10/08)

* Convert requirements from exact to minimum

## v0.5.12 (2017/02/14)

* Unbreak tests on Python 2.x
* PEP8 style fixes

## v0.5.11 (2017/02/14)

* Add a `sort_keys` optional keyword argument to `dumps`
* Correctly parse floats with an exponent

## v0.5.10 (2017/02/13)

* Support string-\>keyword keys in `dumps`
* Add Travis config
* Bump dependencies

## v0.5.9 (2015/07/09)

* Add support to dump `#inst` with microseconds

## v0.5.8 (2015/06/19)

* Fix Python 2/3 support

## v0.5.7 (2015/06/08)

* Fix Python 3 `unichr`/`chr` incompatibility
* Changed Python version detection from exactly equal to 3 to greater than or
equal to 3

## v0.5.6 (2015/05/31)

* Make UTF-8 the default expectation of text type

## v0.5.5 (2015/05/25)

* Fixed string parsing and escaping
* Unicode now consistently used internally
* New method `dumpu` added that returns unicode
* `dumps` method now takes optional encoding arguments: `output_encoding`
(specifies encoding of output string) and `string_encoding` (specifies
encoding of non-unicode strings in object to be serialized), both default to
`'utf-8'`
* `loads` now takes optional argument `input_encoding`, defaults to `'utf-8'`
* New method `loadu` added that assumes unicode input
* Bump dependencies

## v0.5.4 (2015/02/26)

* Fix parsing of booleans before comma

## v0.5.3 (2014/05/03)

## v0.5 (2014/01/25)

* Fix `BaseEdnType.__hash__`
* Fix equality
* Handle escape sequences in strings
* Allow backslashed double-quotes in strings
* Add `<`, `>`, `@`

## v0.4 (2014/01/24)

* Parse empty collections
* Raise an exception on syntax error
* Improves patterns for `SYMBOL`, `TAG`, and `KEYWORD` to more closely match
the [EDN specifications][spec]
* Improve Python 3 support

[spec]: https://github.com/edn-format/edn

## v0.3.6 (2014/01/15)

First published release.
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributing to edn\_format #

## Setup ##

1. Make sure you have a working Python installation (2 or 3). Use either
[Virtualenv][], Vagrant, or a similar tool to create an isolated
environment:
```bash
# 1. One-time: Install Vagrant
#
# macOS
# Install Homebrew from https://brew.sh
# brew cask install virtualbox vagrant
#
# All OSes
# Install from https://www.vagrantup.com/downloads.html

# 2. One-time: Install Vagrant plugin
vagrant plugin install vagrant-vbguest

# 3. This is all you need
vagrant up

# 4. To access the dev environment via ssh
vagrant ssh
cd /vagrant
```

2. Install `edn_format`’s dependencies: `pip install -r requirements.txt`
3. Install `flake8`: `pip install flake8`

[Virtualenv]: https://virtualenv.pypa.io/en/stable/#virtualenv

## Tests ##

Run unit tests with:

python tests.py

Check Python warnings with:

python -Wall -c 'import edn_format'

Run a linter over the code with:

flake8 --max-line-length=100 --exclude=parsetab.py .

## Release a new version ##

To release a new version:

1. Ensure you have [setup GPG](https://help.github.com/en/articles/generating-a-new-gpg-key) and [`twine`](https://pypi.org/project/twine/)
2. Bump up the version number in `setup.py`, e.g. `0.6.3`
3. Create a git tag: `git tag -s v0.6.3 -m 'Version 0.6.3'` (use [signed tags](https://help.github.com/en/articles/signing-tags))
4. Verify git tag: `git tag -v v0.6.3`
5. Push git tag: `git push origin master --tags`
6. Clean your `dist/` directory if it already exists
7. Package the release: `python setup.py sdist bdist_wheel`
8. Check the package: `twine check dist/*`
9. Upload the package: `twine upload dist/*`
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2012-2017, Swaroop C H <swaroop@swaroopch.com>
Copyright 2012-2018, Swaroop C H <swaroop@swaroopch.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

Implements the [EDN format](https://github.com/edn-format/edn) in Python.

All features of EDN are implemented, including custom tagged elements.

[![Build Status](https://travis-ci.org/swaroopch/edn_format.svg?branch=master)](https://travis-ci.org/swaroopch/edn_format)
[![PyPI version](https://img.shields.io/pypi/v/edn_format.svg)](https://pypi.org/project/edn_format/)

## Installation ##

Expand All @@ -16,6 +19,8 @@ Implements the [EDN format](https://github.com/edn-format/edn) in Python.
'#{1 2 3}'
>>> edn_format.loads("[1 true nil]")
[1, True, None]
>>> edn_format.loads_all("1 2 3 4")
[1, 2, 3, 4]
```


Expand All @@ -24,29 +29,13 @@ false, it may be a bug.

See `tests.py` for full details.

## Caveats ##

Almost all features of EDN have been implemented, including custom
tagged elements.

But expect bugs since this has not yet been used in production.

## Contributors ##

Special thanks to the following contributors for making this library
usable:

- [@bfontaine](https://github.com/bfontaine)
- [@marianoguerra](https://github.com/marianoguerra)
- [@bitemyapp](https://github.com/bitemyapp)
- [@jashugan](https://github.com/jashugan)
- [@exilef](https://github.com/exilef)

## Contributor Notes ##

To release a new version:

1. Bump up the version number in `setup.py`, e.g. `0.5.13`
2. Create a git tag: `git tag -a v0.5.13 -m 'Version 0.5.13'`
3. Push git tag: `git push origin master --tags`
4. Make sure you have a [~/.pypirc file](http://docs.python.org/2/distutils/packageindex.html#pypirc) with your PyPI credentials.
5. Run `python setup.py sdist upload`
15 changes: 15 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# https://www.vagrantup.com/docs/
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/cosmic64" # https://cloud-images.ubuntu.com

config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.name = "edn_format"
end

# https://www.vagrantup.com/docs/provisioning/shell.html
config.vm.provision "shell", path: "install.sh", privileged: false, sensitive: true
end
8 changes: 6 additions & 2 deletions edn_format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from .edn_lex import Keyword, Symbol
from .edn_parse import parse as loads
from .edn_parse import add_tag, remove_tag, TaggedElement
from .edn_parse import parse as loads, parse_all as loads_all
from .edn_parse import add_tag, remove_tag, tag, TaggedElement
from .edn_dump import dump as dumps
from .exceptions import EDNDecodeError
from .immutable_dict import ImmutableDict
from .immutable_list import ImmutableList

__all__ = (
'ImmutableList',
'EDNDecodeError',
'ImmutableDict',
'Keyword',
'Symbol',
'TaggedElement',
'add_tag',
'dumps',
'loads',
'loads_all',
'remove_tag',
'tag',
)
17 changes: 13 additions & 4 deletions edn_format/edn_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import datetime
import decimal
import fractions
import itertools
import re
import sys
Expand Down Expand Up @@ -62,12 +63,14 @@ def seq(obj, **kwargs):
def udump(obj,
string_encoding=DEFAULT_INPUT_ENCODING,
keyword_keys=False,
sort_keys=False):
sort_keys=False,
sort_sets=False):

kwargs = {
"string_encoding": string_encoding,
"keyword_keys": keyword_keys,
"sort_keys": sort_keys,
"sort_sets": sort_sets,
}

if obj is None:
Expand All @@ -89,11 +92,13 @@ def udump(obj,
return unicode_escape(obj)
elif isinstance(obj, tuple):
return '({})'.format(seq(obj, **kwargs))
elif isinstance(obj, list):
elif isinstance(obj, (list, ImmutableList)):
return '[{}]'.format(seq(obj, **kwargs))
elif isinstance(obj, ImmutableList):
return '[{}]'.format(seq(obj, **kwargs))
elif isinstance(obj, set) or isinstance(obj, frozenset):
if sort_sets:
obj = sorted(obj)
return '#{{{}}}'.format(seq(obj, **kwargs))
elif isinstance(obj, dict) or isinstance(obj, ImmutableDict):
pairs = obj.items()
Expand All @@ -103,6 +108,8 @@ def udump(obj,
pairs = ((Keyword(k) if isinstance(k, (bytes, basestring)) else k, v) for k, v in pairs)

return '{{{}}}'.format(seq(itertools.chain.from_iterable(pairs), **kwargs))
elif isinstance(obj, fractions.Fraction):
return '{}/{}'.format(obj.numerator, obj.denominator)
elif isinstance(obj, datetime.datetime):
return '#inst "{}"'.format(pyrfc3339.generate(obj, microseconds=True))
elif isinstance(obj, datetime.date):
Expand All @@ -120,11 +127,13 @@ def dump(obj,
string_encoding=DEFAULT_INPUT_ENCODING,
output_encoding=DEFAULT_OUTPUT_ENCODING,
keyword_keys=False,
sort_keys=False):
sort_keys=False,
sort_sets=False):
outcome = udump(obj,
string_encoding=string_encoding,
keyword_keys=keyword_keys,
sort_keys=sort_keys)
sort_keys=sort_keys,
sort_sets=sort_sets)
if __PY3:
return outcome
return outcome.encode(output_encoding)
Loading