diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-12 03:45:20 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-12 03:45:20 +0000 |
commit | 0f992bdc0cb6d43055644219aa1e5fa3a20baf77 (patch) | |
tree | 9baa93596f2d0b82c3dc74ea7c596303e84385ed | |
parent | 94324ee7210ee3b2687b0fddc220137b6480a58b (diff) |
automatic import of python-jsonseq
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-jsonseq.spec | 393 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 395 insertions, 0 deletions
@@ -0,0 +1 @@ +/jsonseq-1.0.0.tar.gz diff --git a/python-jsonseq.spec b/python-jsonseq.spec new file mode 100644 index 0000000..1c3f89c --- /dev/null +++ b/python-jsonseq.spec @@ -0,0 +1,393 @@ +%global _empty_manifest_terminate_build 0 +Name: python-jsonseq +Version: 1.0.0 +Release: 1 +Summary: Python support for RFC 7464 JSON text sequences +License: MIT License +URL: https://github.com/sgillies/jsonseq +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/63/70/faca1f522bc03f92ac75da1eb29fe045bf89246a8e8ed04ccbd563540520/jsonseq-1.0.0.tar.gz +BuildArch: noarch + +Requires: python3-check-manifest +Requires: python3-pytest +Requires: python3-pytest-cover + +%description +# jsonseq + +[RFC 7464 JSON Text Sequences](https://tools.ietf.org/html/rfc7464) encoding and decoding for Python. + +[](https://travis-ci.com/sgillies/jsonseq) +[](https://coveralls.io/github/sgillies/jsonseq?branch=master) +[](https://jsonseq.readthedocs.io/en/latest/?badge=latest) + +## Usage + +The `jsonseq.encode.JSONSeqEncoder` class takes streams of JSON-serializable +Python objects and yields for each object its JSON representation sandwiched +between an optional ASCII record separator (RS, `\x1e`) and a newline (`\n`). + +```python +>>> from jsonseq.encode import JSONSeqEncoder +>>> for chunk in JSONSeqEncoder().encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'{"a": 0, "b": 0}\n' +'{"a": 1, "b": 1}\n' +'{"a": 2, "b": 2}\n' +``` + +The RS allows pretty-printed JSON to be streamed out in sequences that can be +decoded again. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True, indent=2).encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e{\n "a": 0,\n "b": 0\n}\n' +'\x1e{\n "a": 1,\n "b": 1\n}\n' +'\x1e{\n "a": 2,\n "b": 2\n}\n' +``` + +You can also get small chunks of the JSON sequences as they are encoded with +the `iterencode()` method. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True).iterencode(({"a": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e' +'{' +'"a"' +': ' +'0' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'1' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'2' +'}' +'\n' +``` + +You can use either `encode()` or `iterencode()` to copy JSON text sequences to a file. + +```python +with open("/tmp/example.jsons", "w") as f: + for chunk in JSONSeqEncoder(with_rs=True, indent=2).iterencode(({"a": i, "b": i} for i in range(3))): + f.write(chunk) +``` + +There is no need to add a newline when calling the file's `write()` method. +JSONSeqEncoder ensures that it's already there where it needs to be. + +The `jsonseq.decode.JSONSeqDecoder` class takes streams of JSON texts +sandwiched between the optional ASCII record separator (RS, `\x1e`) and +a newline (`\n`) and yields decoded Python objects. + +```python +>>> stream = ['\x1e', '{', '"a"', ': ', '0', '}', '\n', '\x1e', '{', '"a"', ': ', '1', '}', '\n', '\x1e', '{', '"a"', ': ', '2', '}', '\n'] +>>> for obj in JSONSeqDecoder().decode(stream): +... print(repr(obj)) +... +{'a': 0} +{'a': 1} +{'a': 2} +``` + +Objects can be read from a file in the same way. + +```python +>>> with open("/tmp/example.jsons") as f: +... for obj in JSONSeqDecoder().decode(f): +... print(repr(obj)) +... +{'a': 0, 'b': 0} +{'a': 1, 'b': 1} +{'a': 2, 'b': 2} +```` + + + + +%package -n python3-jsonseq +Summary: Python support for RFC 7464 JSON text sequences +Provides: python-jsonseq +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-jsonseq +# jsonseq + +[RFC 7464 JSON Text Sequences](https://tools.ietf.org/html/rfc7464) encoding and decoding for Python. + +[](https://travis-ci.com/sgillies/jsonseq) +[](https://coveralls.io/github/sgillies/jsonseq?branch=master) +[](https://jsonseq.readthedocs.io/en/latest/?badge=latest) + +## Usage + +The `jsonseq.encode.JSONSeqEncoder` class takes streams of JSON-serializable +Python objects and yields for each object its JSON representation sandwiched +between an optional ASCII record separator (RS, `\x1e`) and a newline (`\n`). + +```python +>>> from jsonseq.encode import JSONSeqEncoder +>>> for chunk in JSONSeqEncoder().encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'{"a": 0, "b": 0}\n' +'{"a": 1, "b": 1}\n' +'{"a": 2, "b": 2}\n' +``` + +The RS allows pretty-printed JSON to be streamed out in sequences that can be +decoded again. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True, indent=2).encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e{\n "a": 0,\n "b": 0\n}\n' +'\x1e{\n "a": 1,\n "b": 1\n}\n' +'\x1e{\n "a": 2,\n "b": 2\n}\n' +``` + +You can also get small chunks of the JSON sequences as they are encoded with +the `iterencode()` method. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True).iterencode(({"a": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e' +'{' +'"a"' +': ' +'0' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'1' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'2' +'}' +'\n' +``` + +You can use either `encode()` or `iterencode()` to copy JSON text sequences to a file. + +```python +with open("/tmp/example.jsons", "w") as f: + for chunk in JSONSeqEncoder(with_rs=True, indent=2).iterencode(({"a": i, "b": i} for i in range(3))): + f.write(chunk) +``` + +There is no need to add a newline when calling the file's `write()` method. +JSONSeqEncoder ensures that it's already there where it needs to be. + +The `jsonseq.decode.JSONSeqDecoder` class takes streams of JSON texts +sandwiched between the optional ASCII record separator (RS, `\x1e`) and +a newline (`\n`) and yields decoded Python objects. + +```python +>>> stream = ['\x1e', '{', '"a"', ': ', '0', '}', '\n', '\x1e', '{', '"a"', ': ', '1', '}', '\n', '\x1e', '{', '"a"', ': ', '2', '}', '\n'] +>>> for obj in JSONSeqDecoder().decode(stream): +... print(repr(obj)) +... +{'a': 0} +{'a': 1} +{'a': 2} +``` + +Objects can be read from a file in the same way. + +```python +>>> with open("/tmp/example.jsons") as f: +... for obj in JSONSeqDecoder().decode(f): +... print(repr(obj)) +... +{'a': 0, 'b': 0} +{'a': 1, 'b': 1} +{'a': 2, 'b': 2} +```` + + + + +%package help +Summary: Development documents and examples for jsonseq +Provides: python3-jsonseq-doc +%description help +# jsonseq + +[RFC 7464 JSON Text Sequences](https://tools.ietf.org/html/rfc7464) encoding and decoding for Python. + +[](https://travis-ci.com/sgillies/jsonseq) +[](https://coveralls.io/github/sgillies/jsonseq?branch=master) +[](https://jsonseq.readthedocs.io/en/latest/?badge=latest) + +## Usage + +The `jsonseq.encode.JSONSeqEncoder` class takes streams of JSON-serializable +Python objects and yields for each object its JSON representation sandwiched +between an optional ASCII record separator (RS, `\x1e`) and a newline (`\n`). + +```python +>>> from jsonseq.encode import JSONSeqEncoder +>>> for chunk in JSONSeqEncoder().encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'{"a": 0, "b": 0}\n' +'{"a": 1, "b": 1}\n' +'{"a": 2, "b": 2}\n' +``` + +The RS allows pretty-printed JSON to be streamed out in sequences that can be +decoded again. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True, indent=2).encode(({"a": i, "b": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e{\n "a": 0,\n "b": 0\n}\n' +'\x1e{\n "a": 1,\n "b": 1\n}\n' +'\x1e{\n "a": 2,\n "b": 2\n}\n' +``` + +You can also get small chunks of the JSON sequences as they are encoded with +the `iterencode()` method. + +```python +>>> for chunk in JSONSeqEncoder(with_rs=True).iterencode(({"a": i} for i in range(3))): +... print(repr(chunk)) +... +'\x1e' +'{' +'"a"' +': ' +'0' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'1' +'}' +'\n' +'\x1e' +'{' +'"a"' +': ' +'2' +'}' +'\n' +``` + +You can use either `encode()` or `iterencode()` to copy JSON text sequences to a file. + +```python +with open("/tmp/example.jsons", "w") as f: + for chunk in JSONSeqEncoder(with_rs=True, indent=2).iterencode(({"a": i, "b": i} for i in range(3))): + f.write(chunk) +``` + +There is no need to add a newline when calling the file's `write()` method. +JSONSeqEncoder ensures that it's already there where it needs to be. + +The `jsonseq.decode.JSONSeqDecoder` class takes streams of JSON texts +sandwiched between the optional ASCII record separator (RS, `\x1e`) and +a newline (`\n`) and yields decoded Python objects. + +```python +>>> stream = ['\x1e', '{', '"a"', ': ', '0', '}', '\n', '\x1e', '{', '"a"', ': ', '1', '}', '\n', '\x1e', '{', '"a"', ': ', '2', '}', '\n'] +>>> for obj in JSONSeqDecoder().decode(stream): +... print(repr(obj)) +... +{'a': 0} +{'a': 1} +{'a': 2} +``` + +Objects can be read from a file in the same way. + +```python +>>> with open("/tmp/example.jsons") as f: +... for obj in JSONSeqDecoder().decode(f): +... print(repr(obj)) +... +{'a': 0, 'b': 0} +{'a': 1, 'b': 1} +{'a': 2, 'b': 2} +```` + + + + +%prep +%autosetup -n jsonseq-1.0.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-jsonseq -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.0-1 +- Package Spec generated @@ -0,0 +1 @@ +8ecd561fa318378f3df49f7c0497799f jsonseq-1.0.0.tar.gz |