diff options
-rw-r--r-- | CHANGES.txt | 8 | ||||
-rw-r--r-- | conf.py | 2 | ||||
-rw-r--r-- | index.rst | 20 | ||||
-rw-r--r-- | scripts/release.py (renamed from scripts/artifacts.py) | 26 | ||||
-rw-r--r-- | setup.py | 3 | ||||
-rw-r--r-- | simplejson/__init__.py | 24 |
6 files changed, 54 insertions, 29 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index f64c3a0..2237c92 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,11 @@ +Version 3.16.1 released 2018-09-06 + +* Added examples for JSON lines use cases +* Add wheels for more Python versions and platforms + https://github.com/simplejson/simplejson/pull/234 + https://github.com/simplejson/simplejson/pull/233 + https://github.com/simplejson/simplejson/pull/231 + Version 3.16.0 released 2018-06-28 * Restore old behavior with regard to the type of decoded empty @@ -44,7 +44,7 @@ copyright = '2018, Bob Ippolito' # The short X.Y version. version = '3.16' # The full version, including alpha/beta/rc tags. -release = '3.16.0' +release = '3.16.1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -124,6 +124,26 @@ Using :mod:`simplejson.tool` from the shell to validate and pretty-print:: .. highlight:: python +Parsing multiple documents serialized as JSON lines (newline-delimited JSON):: + + >>> import simplejson as json + >>> def loads_lines(docs): + ... for doc in docs.splitlines(): + ... yield json.loads(doc) + ... + >>> sum(doc["count"] for doc in loads_lines('{"count":1}\n{"count":2}\n{"count":3}\n')) + 6 + +Serializing multiple objects to JSON lines (newline-delimited JSON):: + + >>> import simplejson as json + >>> def dumps_lines(objs): + ... for obj in objs: + ... yield json.dumps(obj, separators=(',',':')) + '\n' + ... + >>> ''.join(dumps_lines([{'count': 1}, {'count': 2}, {'count': 3}])) + '{"count":1}\n{"count":2}\n{"count":3}\n' + .. note:: JSON is a subset of `YAML <http://yaml.org/>`_ 1.2. The JSON produced by diff --git a/scripts/artifacts.py b/scripts/release.py index a8e41c4..c540640 100644 --- a/scripts/artifacts.py +++ b/scripts/release.py @@ -57,28 +57,6 @@ def artifact_matcher(version): return matches -def sign_artifacts(version): - artifacts = set(os.listdir('dist')) - matches = artifact_matcher(version) - passphrase = getpass.getpass('\nGPG Passphrase:') - for fn in artifacts: - if matches(fn) and '{}.asc'.format(fn) not in artifacts: - sign_artifact(os.path.join('dist', fn), passphrase) - - -def sign_artifact(path, passphrase): - cmd = [ - 'gpg', - '--detach-sign', - '--batch', - '--passphrase-fd', '0', - '--armor', - path - ] - print(' '.join(cmd)) - subprocess.run(cmd, check=True, input=passphrase, encoding='utf8') - - def upload_artifacts(version): artifacts = set(os.listdir('dist')) matches = artifact_matcher(version) @@ -97,9 +75,7 @@ def main(): pass download_appveyor_artifacts() download_github_artifacts() - version = get_version() - sign_artifacts(version) - upload_artifacts(version) + upload_artifacts(get_version()) if __name__ == '__main__': @@ -12,7 +12,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.16.0' +VERSION = '3.16.1' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: @@ -35,6 +35,7 @@ CLASSIFIERS = [ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Libraries :: Python Modules', diff --git a/simplejson/__init__.py b/simplejson/__init__.py index 0556a7a..9d9b737 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -87,7 +87,6 @@ Specializing JSON object encoding:: >>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j)) '[2.0, 1.0]' - Using simplejson.tool from the shell to validate and pretty-print:: $ echo '{"json":"obj"}' | python -m simplejson.tool @@ -96,9 +95,30 @@ Using simplejson.tool from the shell to validate and pretty-print:: } $ echo '{ 1.2:3.4}' | python -m simplejson.tool Expecting property name: line 1 column 3 (char 2) + +Parsing multiple documents serialized as JSON lines (newline-delimited JSON):: + + >>> import simplejson as json + >>> def loads_lines(docs): + ... for doc in docs.splitlines(): + ... yield json.loads(doc) + ... + >>> sum(doc["count"] for doc in loads_lines('{"count":1}\n{"count":2}\n{"count":3}\n')) + 6 + +Serializing multiple objects to JSON lines (newline-delimited JSON):: + + >>> import simplejson as json + >>> def dumps_lines(objs): + ... for obj in objs: + ... yield json.dumps(obj, separators=(',',':')) + '\n' + ... + >>> ''.join(dumps_lines([{'count': 1}, {'count': 2}, {'count': 3}])) + '{"count":1}\n{"count":2}\n{"count":3}\n' + """ from __future__ import absolute_import -__version__ = '3.16.0' +__version__ = '3.16.1' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', |