diff options
author | CoprDistGit <infra@openeuler.org> | 2023-03-09 15:01:37 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-03-09 15:01:37 +0000 |
commit | 369a6d5444251eb08da0b78adb3a8d64901d717d (patch) | |
tree | 7c22bd3b89151431361ce183acfb1f9855f8b9c8 | |
parent | 2ad7081bf87d77ad3b9990e487040ebe13b7f4fc (diff) |
automatic import of python-phpserialize
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-phpserialize.spec | 231 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 233 insertions, 0 deletions
@@ -0,0 +1 @@ +/phpserialize-1.3.tar.gz diff --git a/python-phpserialize.spec b/python-phpserialize.spec new file mode 100644 index 0000000..d58b716 --- /dev/null +++ b/python-phpserialize.spec @@ -0,0 +1,231 @@ +%global _empty_manifest_terminate_build 0 +Name: python-phpserialize +Version: 1.3 +Release: 1 +Summary: a port of the serialize and unserialize functions of php to python. +License: UNKNOWN +URL: http://github.com/mitsuhiko/phpserialize +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ec/6d/437efc62d7327bcbcfa18f6bb27a0de3c8621e9af045dfc322d12eb310c9/phpserialize-1.3.tar.gz +BuildArch: noarch + + +%description +>>> from phpserialize import * +>>> obj = dumps("Hello World") +>>> loads(obj) +'Hello World' +Due to the fact that PHP doesn't know the concept of lists, lists +are serialized like hash-maps in PHP. As a matter of fact the +reverse value of a serialized list is a dict: +>>> loads(dumps(range(2))) +{0: 0, 1: 1} +If you want to have a list again, you can use the `dict_to_list` +helper function: +>>> dict_to_list(loads(dumps(range(2)))) +[0, 1] +It's also possible to convert into a tuple by using the `dict_to_tuple` +function: +>>> dict_to_tuple(loads(dumps((1, 2, 3)))) +(1, 2, 3) +Another problem are unicode strings. By default unicode strings are +encoded to 'utf-8' but not decoded on `unserialize`. The reason for +this is that phpserialize can't guess if you have binary or text data +in the strings: +>>> loads(dumps(u'Hello W\xf6rld')) +'Hello W\xc3\xb6rld' +If you know that you have only text data of a known charset in the result +you can decode strings by setting `decode_strings` to True when calling +loads: +>>> loads(dumps(u'Hello W\xf6rld'), decode_strings=True) +u'Hello W\xf6rld' +Dictionary keys are limited to strings and integers. `None` is converted +into an empty string and floats and booleans into integers for PHP +compatibility: +>>> loads(dumps({None: 14, 42.23: 'foo', True: [1, 2, 3]})) +{'': 14, 1: {0: 1, 1: 2, 2: 3}, 42: 'foo'} +It also provides functions to read from file-like objects: +>>> from StringIO import StringIO +>>> stream = StringIO('a:2:{i:0;i:1;i:1;i:2;}') +>>> dict_to_list(load(stream)) +[1, 2] +And to write to those: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> stream.getvalue() +'a:2:{i:0;i:1;i:1;i:2;}' +Like `pickle` chaining of objects is supported: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> dump("foo", stream) +>>> stream.seek(0) +>>> load(stream) +{0: 1, 1: 2} +>>> load(stream) +'foo' +This feature however is not supported in PHP. PHP will only unserialize +the first object. + +%package -n python3-phpserialize +Summary: a port of the serialize and unserialize functions of php to python. +Provides: python-phpserialize +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-phpserialize +>>> from phpserialize import * +>>> obj = dumps("Hello World") +>>> loads(obj) +'Hello World' +Due to the fact that PHP doesn't know the concept of lists, lists +are serialized like hash-maps in PHP. As a matter of fact the +reverse value of a serialized list is a dict: +>>> loads(dumps(range(2))) +{0: 0, 1: 1} +If you want to have a list again, you can use the `dict_to_list` +helper function: +>>> dict_to_list(loads(dumps(range(2)))) +[0, 1] +It's also possible to convert into a tuple by using the `dict_to_tuple` +function: +>>> dict_to_tuple(loads(dumps((1, 2, 3)))) +(1, 2, 3) +Another problem are unicode strings. By default unicode strings are +encoded to 'utf-8' but not decoded on `unserialize`. The reason for +this is that phpserialize can't guess if you have binary or text data +in the strings: +>>> loads(dumps(u'Hello W\xf6rld')) +'Hello W\xc3\xb6rld' +If you know that you have only text data of a known charset in the result +you can decode strings by setting `decode_strings` to True when calling +loads: +>>> loads(dumps(u'Hello W\xf6rld'), decode_strings=True) +u'Hello W\xf6rld' +Dictionary keys are limited to strings and integers. `None` is converted +into an empty string and floats and booleans into integers for PHP +compatibility: +>>> loads(dumps({None: 14, 42.23: 'foo', True: [1, 2, 3]})) +{'': 14, 1: {0: 1, 1: 2, 2: 3}, 42: 'foo'} +It also provides functions to read from file-like objects: +>>> from StringIO import StringIO +>>> stream = StringIO('a:2:{i:0;i:1;i:1;i:2;}') +>>> dict_to_list(load(stream)) +[1, 2] +And to write to those: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> stream.getvalue() +'a:2:{i:0;i:1;i:1;i:2;}' +Like `pickle` chaining of objects is supported: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> dump("foo", stream) +>>> stream.seek(0) +>>> load(stream) +{0: 1, 1: 2} +>>> load(stream) +'foo' +This feature however is not supported in PHP. PHP will only unserialize +the first object. + +%package help +Summary: Development documents and examples for phpserialize +Provides: python3-phpserialize-doc +%description help +>>> from phpserialize import * +>>> obj = dumps("Hello World") +>>> loads(obj) +'Hello World' +Due to the fact that PHP doesn't know the concept of lists, lists +are serialized like hash-maps in PHP. As a matter of fact the +reverse value of a serialized list is a dict: +>>> loads(dumps(range(2))) +{0: 0, 1: 1} +If you want to have a list again, you can use the `dict_to_list` +helper function: +>>> dict_to_list(loads(dumps(range(2)))) +[0, 1] +It's also possible to convert into a tuple by using the `dict_to_tuple` +function: +>>> dict_to_tuple(loads(dumps((1, 2, 3)))) +(1, 2, 3) +Another problem are unicode strings. By default unicode strings are +encoded to 'utf-8' but not decoded on `unserialize`. The reason for +this is that phpserialize can't guess if you have binary or text data +in the strings: +>>> loads(dumps(u'Hello W\xf6rld')) +'Hello W\xc3\xb6rld' +If you know that you have only text data of a known charset in the result +you can decode strings by setting `decode_strings` to True when calling +loads: +>>> loads(dumps(u'Hello W\xf6rld'), decode_strings=True) +u'Hello W\xf6rld' +Dictionary keys are limited to strings and integers. `None` is converted +into an empty string and floats and booleans into integers for PHP +compatibility: +>>> loads(dumps({None: 14, 42.23: 'foo', True: [1, 2, 3]})) +{'': 14, 1: {0: 1, 1: 2, 2: 3}, 42: 'foo'} +It also provides functions to read from file-like objects: +>>> from StringIO import StringIO +>>> stream = StringIO('a:2:{i:0;i:1;i:1;i:2;}') +>>> dict_to_list(load(stream)) +[1, 2] +And to write to those: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> stream.getvalue() +'a:2:{i:0;i:1;i:1;i:2;}' +Like `pickle` chaining of objects is supported: +>>> stream = StringIO() +>>> dump([1, 2], stream) +>>> dump("foo", stream) +>>> stream.seek(0) +>>> load(stream) +{0: 1, 1: 2} +>>> load(stream) +'foo' +This feature however is not supported in PHP. PHP will only unserialize +the first object. + +%prep +%autosetup -n phpserialize-1.3 + +%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-phpserialize -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu Mar 09 2023 Python_Bot <Python_Bot@openeuler.org> - 1.3-1 +- Package Spec generated @@ -0,0 +1 @@ +cbf88a62e04135e3be3c7fe412525b8b phpserialize-1.3.tar.gz |