summaryrefslogtreecommitdiff
path: root/python-multifruits.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-multifruits.spec')
-rw-r--r--python-multifruits.spec381
1 files changed, 381 insertions, 0 deletions
diff --git a/python-multifruits.spec b/python-multifruits.spec
new file mode 100644
index 0000000..01b2206
--- /dev/null
+++ b/python-multifruits.spec
@@ -0,0 +1,381 @@
+%global _empty_manifest_terminate_build 0
+Name: python-multifruits
+Version: 0.1.5
+Release: 1
+Summary: Tasty multipart form data parser built with cython.
+License: MIT
+URL: https://github.com/pyrates/multifruits
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/52/0f/43663f2203d614d80c3817b7becfeefa74910223d62766173a16cf8f4137/multifruits-0.1.5.tar.gz
+BuildArch: noarch
+
+
+%description
+# Multifruits
+
+Tasty multipart form data parser built with cython.
+
+
+## Install
+
+ pip install multifruits
+
+
+## Usage
+
+`multifruits` has one `Parser` class and two helpers: `extract_filename` and
+`parse_content_disposition`.
+
+
+#### `Parser`
+
+`Parser` needs the `Content-Type` header value and a handler, which could
+define one or more of these methods:
+
+```python
+on_body_begin()
+on_part_begin()
+on_header(name: bytes, value: bytes)
+on_headers_complete()
+on_data(data: bytes)
+on_part_complete()
+on_body_complete()
+```
+
+Example:
+
+```python
+from multifruits import Parser
+
+class MyHandler:
+
+ def on_part_begin(self):
+ self.part = MyPart()
+
+ def on_header(self, name, value):
+ self.part.headers[name] = value
+
+ def on_data(self, data):
+ self.part.write(data)
+
+handler = MyHandler()
+parser = Parser(handler, request.headers['Content-Type'])
+parser.feed_data(request.body) # You can pass chunks
+```
+
+#### Helpers
+
+##### `parse_content_disposition`
+
+Takes raw `Content-Disposition` header value and returns the disposition type
+(`attachment`, `form-data`, `inline` and so on) and the parameters parsed as a
+dictionary.
+
+Example:
+
+```python
+dtype, params = parse_content_disposition(b'inline; filename="foo.html"')
+assert dtype == b'inline'
+assert params == {b'filename': b'foo.html'}
+```
+
+
+##### `extract_filename`
+
+Takes parameters from `parse_content_disposition` as a dict and tries to
+return the appropriated `str` filename (like `filename*`).
+
+Example:
+
+```python
+assert extract_filename({
+ b'filename*': "UTF-8''foo-ä-€.html".encode()
+}) == 'foo-ä-€.html'
+```
+
+
+## Build from source
+
+You need a virtualenv with cython installed, then:
+
+ git clone https://github.com/pyrates/multifruits
+ cd multifruits
+ make compile
+ python setup.py develop
+
+## Tests
+
+To run tests:
+
+ make test
+
+
+## Acknowledgements
+
+- https://github.com/iafonov/multipart-parser-c/
+- https://github.com/francoiscolas/multipart-parser/
+- https://github.com/felixge/node-formidable/
+
+%package -n python3-multifruits
+Summary: Tasty multipart form data parser built with cython.
+Provides: python-multifruits
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-multifruits
+# Multifruits
+
+Tasty multipart form data parser built with cython.
+
+
+## Install
+
+ pip install multifruits
+
+
+## Usage
+
+`multifruits` has one `Parser` class and two helpers: `extract_filename` and
+`parse_content_disposition`.
+
+
+#### `Parser`
+
+`Parser` needs the `Content-Type` header value and a handler, which could
+define one or more of these methods:
+
+```python
+on_body_begin()
+on_part_begin()
+on_header(name: bytes, value: bytes)
+on_headers_complete()
+on_data(data: bytes)
+on_part_complete()
+on_body_complete()
+```
+
+Example:
+
+```python
+from multifruits import Parser
+
+class MyHandler:
+
+ def on_part_begin(self):
+ self.part = MyPart()
+
+ def on_header(self, name, value):
+ self.part.headers[name] = value
+
+ def on_data(self, data):
+ self.part.write(data)
+
+handler = MyHandler()
+parser = Parser(handler, request.headers['Content-Type'])
+parser.feed_data(request.body) # You can pass chunks
+```
+
+#### Helpers
+
+##### `parse_content_disposition`
+
+Takes raw `Content-Disposition` header value and returns the disposition type
+(`attachment`, `form-data`, `inline` and so on) and the parameters parsed as a
+dictionary.
+
+Example:
+
+```python
+dtype, params = parse_content_disposition(b'inline; filename="foo.html"')
+assert dtype == b'inline'
+assert params == {b'filename': b'foo.html'}
+```
+
+
+##### `extract_filename`
+
+Takes parameters from `parse_content_disposition` as a dict and tries to
+return the appropriated `str` filename (like `filename*`).
+
+Example:
+
+```python
+assert extract_filename({
+ b'filename*': "UTF-8''foo-ä-€.html".encode()
+}) == 'foo-ä-€.html'
+```
+
+
+## Build from source
+
+You need a virtualenv with cython installed, then:
+
+ git clone https://github.com/pyrates/multifruits
+ cd multifruits
+ make compile
+ python setup.py develop
+
+## Tests
+
+To run tests:
+
+ make test
+
+
+## Acknowledgements
+
+- https://github.com/iafonov/multipart-parser-c/
+- https://github.com/francoiscolas/multipart-parser/
+- https://github.com/felixge/node-formidable/
+
+%package help
+Summary: Development documents and examples for multifruits
+Provides: python3-multifruits-doc
+%description help
+# Multifruits
+
+Tasty multipart form data parser built with cython.
+
+
+## Install
+
+ pip install multifruits
+
+
+## Usage
+
+`multifruits` has one `Parser` class and two helpers: `extract_filename` and
+`parse_content_disposition`.
+
+
+#### `Parser`
+
+`Parser` needs the `Content-Type` header value and a handler, which could
+define one or more of these methods:
+
+```python
+on_body_begin()
+on_part_begin()
+on_header(name: bytes, value: bytes)
+on_headers_complete()
+on_data(data: bytes)
+on_part_complete()
+on_body_complete()
+```
+
+Example:
+
+```python
+from multifruits import Parser
+
+class MyHandler:
+
+ def on_part_begin(self):
+ self.part = MyPart()
+
+ def on_header(self, name, value):
+ self.part.headers[name] = value
+
+ def on_data(self, data):
+ self.part.write(data)
+
+handler = MyHandler()
+parser = Parser(handler, request.headers['Content-Type'])
+parser.feed_data(request.body) # You can pass chunks
+```
+
+#### Helpers
+
+##### `parse_content_disposition`
+
+Takes raw `Content-Disposition` header value and returns the disposition type
+(`attachment`, `form-data`, `inline` and so on) and the parameters parsed as a
+dictionary.
+
+Example:
+
+```python
+dtype, params = parse_content_disposition(b'inline; filename="foo.html"')
+assert dtype == b'inline'
+assert params == {b'filename': b'foo.html'}
+```
+
+
+##### `extract_filename`
+
+Takes parameters from `parse_content_disposition` as a dict and tries to
+return the appropriated `str` filename (like `filename*`).
+
+Example:
+
+```python
+assert extract_filename({
+ b'filename*': "UTF-8''foo-ä-€.html".encode()
+}) == 'foo-ä-€.html'
+```
+
+
+## Build from source
+
+You need a virtualenv with cython installed, then:
+
+ git clone https://github.com/pyrates/multifruits
+ cd multifruits
+ make compile
+ python setup.py develop
+
+## Tests
+
+To run tests:
+
+ make test
+
+
+## Acknowledgements
+
+- https://github.com/iafonov/multipart-parser-c/
+- https://github.com/francoiscolas/multipart-parser/
+- https://github.com/felixge/node-formidable/
+
+%prep
+%autosetup -n multifruits-0.1.5
+
+%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-multifruits -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.5-1
+- Package Spec generated