diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:16:40 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:16:40 +0000 |
commit | 9ac53368c2ca497e64dda773ab93c99ca74d5ae7 (patch) | |
tree | eda4d2c5c5ba84796ea85cc5c48b600e479f835b | |
parent | 6790b77650d74008c662c273c9b81b1549ed50c5 (diff) |
automatic import of python-stream-inflate
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-stream-inflate.spec | 231 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 233 insertions, 0 deletions
@@ -0,0 +1 @@ +/stream-inflate-0.0.14.tar.gz diff --git a/python-stream-inflate.spec b/python-stream-inflate.spec new file mode 100644 index 0000000..be6ea42 --- /dev/null +++ b/python-stream-inflate.spec @@ -0,0 +1,231 @@ +%global _empty_manifest_terminate_build 0 +Name: python-stream-inflate +Version: 0.0.14 +Release: 1 +Summary: Uncompress DEFLATE streams in pure Python +License: MIT License +URL: https://github.com/michalc/stream-inflate +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/f0/0f/f79ed847d995c2e24a95d59b6f91c827ec5465c37c54b11a59f88f832377/stream-inflate-0.0.14.tar.gz +BuildArch: noarch + + +%description +# stream-inflate [](https://circleci.com/gh/michalc/stream-inflate) [](https://codeclimate.com/github/michalc/stream-inflate/test_coverage) + +Uncompress Deflate and Deflate64 streams in pure Python. + + +## Installation + +```bash +pip install stream-inflate +``` + + +## Usage + +To uncompress Deflate, use the `stream_inflate` function. + +```python +from stream_inflate import stream_inflate +import httpx + +def compressed_chunks(): + # Iterable that yields the bytes of a DEFLATE-compressed stream + with httpx.stream('GET', 'https://www.example.com/my.txt') as r: + yield from r.iter_raw(chunk_size=65536) + +for uncompressed_chunk in stream_inflate()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +To uncompress Deflate64, use the `stream_inflate64` function. + +```python +for uncompressed_chunk in stream_inflate64()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +For Deflate streams of unknown length where there may be other data _after_ the compressed part, the following pattern can be used to find how many bytes are not part of the compressed stream. + +```python +uncompressed_chunks, is_done, num_bytes_unconsumed = stream_inflate() +it = iter(compressed_chunks()) + +while not is_done(): + chunk = next(it) + for uncompressed in uncompressed_chunks((chunk,)) + print(uncompressed) + +print(num_bytes_unconsumed()) +``` + +This can be useful in certain ZIP files. + + + + +%package -n python3-stream-inflate +Summary: Uncompress DEFLATE streams in pure Python +Provides: python-stream-inflate +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-stream-inflate +# stream-inflate [](https://circleci.com/gh/michalc/stream-inflate) [](https://codeclimate.com/github/michalc/stream-inflate/test_coverage) + +Uncompress Deflate and Deflate64 streams in pure Python. + + +## Installation + +```bash +pip install stream-inflate +``` + + +## Usage + +To uncompress Deflate, use the `stream_inflate` function. + +```python +from stream_inflate import stream_inflate +import httpx + +def compressed_chunks(): + # Iterable that yields the bytes of a DEFLATE-compressed stream + with httpx.stream('GET', 'https://www.example.com/my.txt') as r: + yield from r.iter_raw(chunk_size=65536) + +for uncompressed_chunk in stream_inflate()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +To uncompress Deflate64, use the `stream_inflate64` function. + +```python +for uncompressed_chunk in stream_inflate64()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +For Deflate streams of unknown length where there may be other data _after_ the compressed part, the following pattern can be used to find how many bytes are not part of the compressed stream. + +```python +uncompressed_chunks, is_done, num_bytes_unconsumed = stream_inflate() +it = iter(compressed_chunks()) + +while not is_done(): + chunk = next(it) + for uncompressed in uncompressed_chunks((chunk,)) + print(uncompressed) + +print(num_bytes_unconsumed()) +``` + +This can be useful in certain ZIP files. + + + + +%package help +Summary: Development documents and examples for stream-inflate +Provides: python3-stream-inflate-doc +%description help +# stream-inflate [](https://circleci.com/gh/michalc/stream-inflate) [](https://codeclimate.com/github/michalc/stream-inflate/test_coverage) + +Uncompress Deflate and Deflate64 streams in pure Python. + + +## Installation + +```bash +pip install stream-inflate +``` + + +## Usage + +To uncompress Deflate, use the `stream_inflate` function. + +```python +from stream_inflate import stream_inflate +import httpx + +def compressed_chunks(): + # Iterable that yields the bytes of a DEFLATE-compressed stream + with httpx.stream('GET', 'https://www.example.com/my.txt') as r: + yield from r.iter_raw(chunk_size=65536) + +for uncompressed_chunk in stream_inflate()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +To uncompress Deflate64, use the `stream_inflate64` function. + +```python +for uncompressed_chunk in stream_inflate64()[0](compressed_chunks()): + print(uncompressed_chunk) +``` + +For Deflate streams of unknown length where there may be other data _after_ the compressed part, the following pattern can be used to find how many bytes are not part of the compressed stream. + +```python +uncompressed_chunks, is_done, num_bytes_unconsumed = stream_inflate() +it = iter(compressed_chunks()) + +while not is_done(): + chunk = next(it) + for uncompressed in uncompressed_chunks((chunk,)) + print(uncompressed) + +print(num_bytes_unconsumed()) +``` + +This can be useful in certain ZIP files. + + + + +%prep +%autosetup -n stream-inflate-0.0.14 + +%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-stream-inflate -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.14-1 +- Package Spec generated @@ -0,0 +1 @@ +4b31389d58fe63dc846c8013da822011 stream-inflate-0.0.14.tar.gz |