diff options
author | CoprDistGit <infra@openeuler.org> | 2023-03-09 13:09:47 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-03-09 13:09:47 +0000 |
commit | fee4e8d641d55140a1caac2763907877f475413b (patch) | |
tree | 0de7e4c5461d0a3df7b425b4c8a3bddaefae40c4 | |
parent | 7751be336e7cfd9010ea406c9a050429dafdf3c9 (diff) |
automatic import of python-itypes
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-itypes.spec | 537 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 539 insertions, 0 deletions
@@ -0,0 +1 @@ +/itypes-1.2.0.tar.gz diff --git a/python-itypes.spec b/python-itypes.spec new file mode 100644 index 0000000..4ecc4cf --- /dev/null +++ b/python-itypes.spec @@ -0,0 +1,537 @@ +%global _empty_manifest_terminate_build 0 +Name: python-itypes +Version: 1.2.0 +Release: 1 +Summary: Simple immutable types for python. +License: BSD +URL: http://github.com/PavanTatikonda/itypes +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0e/53/764524b3907d0af00523f8794daca181c08ca7cb32ceee25a0754d5e63a5/itypes-1.2.0.tar.gz +BuildArch: noarch + + +%description +# itypes + +[](https://travis-ci.org/PavanTatikonda/itypes) + +Basic immutable container types for Python. + +A simple implementation that's designed for simplicity over performance. + +Use these in circumstances where it may result in more comprehensible code, +or when you want to create custom types with restricted, immutable interfaces. + +For an alternative implementation designed for performance, +please see [pyrsistent](https://github.com/tobgu/pyrsistent). + +### Installation + +Install using `pip`: + + pip install itypes + +### Instantiating dictionaries and lists. + + >>> import itypes + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> l = itypes.List(['a', 'b', 'c']) + +### On instantiation, nested types are coerced to immutables. + + >>> d = itypes.Dict({'a': 123, 'b': ['a', 'b', 'c']}) + >>> d['b'] + List(['a', 'b', 'c']) + +### Assignments and deletions return new copies. + +Methods: `set(key, value)`, `delete(key)` + + >>> d2 = d.set('c', 456) + >>> d2 + Dict({'a': 123, 'b': ['a', 'b', 'c'], 'c': 456}) + >>> d3 = d2.delete('a') + >>> d3 + Dict({'b': ['a', 'b', 'c'], 'c': 456}) + +### Standard assignments and deletions fail. + + >>> d['z'] = 123 + TypeError: 'Dict' object doesn't support item assignment + >>> del(d['c']) + TypeError: 'Dict' object doesn't support item deletion + +### Nested lookups. + +Method: `get_in(keys, default=None)` + + >>> d['b'][-1] + 'c' + >>> d['b'][5] + IndexError: list index out of range + >>> d.get_in(['b', -1]) + 'c' + >>> d.get_in(['b', 5]) + None + +### Nested assignments and deletions. + +Methods: `set_in(keys, value)`, `delete_in(keys)` + + >>> d2 = d.set_in(['b', 1], 'xxx') + >>> d2 + Dict({'a': 123, 'b': ['a', 'xxx', 'c']}) + >>> d3 = d2.delete_in(['b', 0]) + >>> d3 + Dict({'a': 123, 'b': ['xxx', 'c']}) + +### Equality works against standard types. + + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> d == {'a': 1, 'b': 2, 'c': 3} + True + +### Objects are hashable. + + >>> hash(d) + 277752239 + +### Shortcuts for switching between mutable and immutable types. + +Functions: `to_mutable(instance)`, `to_immutable(value)` + + >>> value = itypes.to_mutable(d) + >>> value + {'a': 123, 'b': ['a', 'b', 'c']} + >>> itypes.to_immutable(value) + Dict({'a': 123, 'b': ['a', 'b', 'c']}) + +### Subclassing. + +Only private attribute names may be set on instances. Use `@property` for attribute access. + +Define a `.clone(self, data)` method if objects have additional state. + +Example: + + class Configuration(itypes.Dict): + def __init__(self, title, *args, **kwargs): + self._title = title + super(Configuration, self).__init__(*args, **kwargs) + + @property + def title(self): + return self._title + + def clone(self, data): + return Configuration(self._title, data) + +Using the custom class: + + >>> config = Configuration('worker-process', {'hostname': 'example.com', 'dynos': 4}) + >>> config.title + 'worker-process' + >>> new = config.set('dynos', 2) + >>> new + Configuration({'dynos': 2, 'hostname': 'example.com'}) + >>> new.title + 'worker-process' + +### Custom immutable objects. + +Subclass `itypes.Object` for an object that prevents setting public attributes. + + >>> class Custom(itypes.Object): + ... pass + +Only private attribute names may be set on instances. Use `@property` for attribute access. + + >>> class Document(itypes.Object): + ... def __init__(self, title, content): + ... self._title = title + ... self._content = title + ... @property + ... def title(self): + ... return self._title + ... @property + ... def content(self): + ... return self._content + +Using immutable objects: + + >>> doc = Document(title='Immutability', content='For simplicity') + >>> doc.title + 'Immutability' + >>> doc.title = 'Changed' + TypeError: 'Document' object doesn't support property assignment. + + + + +%package -n python3-itypes +Summary: Simple immutable types for python. +Provides: python-itypes +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-itypes +# itypes + +[](https://travis-ci.org/PavanTatikonda/itypes) + +Basic immutable container types for Python. + +A simple implementation that's designed for simplicity over performance. + +Use these in circumstances where it may result in more comprehensible code, +or when you want to create custom types with restricted, immutable interfaces. + +For an alternative implementation designed for performance, +please see [pyrsistent](https://github.com/tobgu/pyrsistent). + +### Installation + +Install using `pip`: + + pip install itypes + +### Instantiating dictionaries and lists. + + >>> import itypes + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> l = itypes.List(['a', 'b', 'c']) + +### On instantiation, nested types are coerced to immutables. + + >>> d = itypes.Dict({'a': 123, 'b': ['a', 'b', 'c']}) + >>> d['b'] + List(['a', 'b', 'c']) + +### Assignments and deletions return new copies. + +Methods: `set(key, value)`, `delete(key)` + + >>> d2 = d.set('c', 456) + >>> d2 + Dict({'a': 123, 'b': ['a', 'b', 'c'], 'c': 456}) + >>> d3 = d2.delete('a') + >>> d3 + Dict({'b': ['a', 'b', 'c'], 'c': 456}) + +### Standard assignments and deletions fail. + + >>> d['z'] = 123 + TypeError: 'Dict' object doesn't support item assignment + >>> del(d['c']) + TypeError: 'Dict' object doesn't support item deletion + +### Nested lookups. + +Method: `get_in(keys, default=None)` + + >>> d['b'][-1] + 'c' + >>> d['b'][5] + IndexError: list index out of range + >>> d.get_in(['b', -1]) + 'c' + >>> d.get_in(['b', 5]) + None + +### Nested assignments and deletions. + +Methods: `set_in(keys, value)`, `delete_in(keys)` + + >>> d2 = d.set_in(['b', 1], 'xxx') + >>> d2 + Dict({'a': 123, 'b': ['a', 'xxx', 'c']}) + >>> d3 = d2.delete_in(['b', 0]) + >>> d3 + Dict({'a': 123, 'b': ['xxx', 'c']}) + +### Equality works against standard types. + + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> d == {'a': 1, 'b': 2, 'c': 3} + True + +### Objects are hashable. + + >>> hash(d) + 277752239 + +### Shortcuts for switching between mutable and immutable types. + +Functions: `to_mutable(instance)`, `to_immutable(value)` + + >>> value = itypes.to_mutable(d) + >>> value + {'a': 123, 'b': ['a', 'b', 'c']} + >>> itypes.to_immutable(value) + Dict({'a': 123, 'b': ['a', 'b', 'c']}) + +### Subclassing. + +Only private attribute names may be set on instances. Use `@property` for attribute access. + +Define a `.clone(self, data)` method if objects have additional state. + +Example: + + class Configuration(itypes.Dict): + def __init__(self, title, *args, **kwargs): + self._title = title + super(Configuration, self).__init__(*args, **kwargs) + + @property + def title(self): + return self._title + + def clone(self, data): + return Configuration(self._title, data) + +Using the custom class: + + >>> config = Configuration('worker-process', {'hostname': 'example.com', 'dynos': 4}) + >>> config.title + 'worker-process' + >>> new = config.set('dynos', 2) + >>> new + Configuration({'dynos': 2, 'hostname': 'example.com'}) + >>> new.title + 'worker-process' + +### Custom immutable objects. + +Subclass `itypes.Object` for an object that prevents setting public attributes. + + >>> class Custom(itypes.Object): + ... pass + +Only private attribute names may be set on instances. Use `@property` for attribute access. + + >>> class Document(itypes.Object): + ... def __init__(self, title, content): + ... self._title = title + ... self._content = title + ... @property + ... def title(self): + ... return self._title + ... @property + ... def content(self): + ... return self._content + +Using immutable objects: + + >>> doc = Document(title='Immutability', content='For simplicity') + >>> doc.title + 'Immutability' + >>> doc.title = 'Changed' + TypeError: 'Document' object doesn't support property assignment. + + + + +%package help +Summary: Development documents and examples for itypes +Provides: python3-itypes-doc +%description help +# itypes + +[](https://travis-ci.org/PavanTatikonda/itypes) + +Basic immutable container types for Python. + +A simple implementation that's designed for simplicity over performance. + +Use these in circumstances where it may result in more comprehensible code, +or when you want to create custom types with restricted, immutable interfaces. + +For an alternative implementation designed for performance, +please see [pyrsistent](https://github.com/tobgu/pyrsistent). + +### Installation + +Install using `pip`: + + pip install itypes + +### Instantiating dictionaries and lists. + + >>> import itypes + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> l = itypes.List(['a', 'b', 'c']) + +### On instantiation, nested types are coerced to immutables. + + >>> d = itypes.Dict({'a': 123, 'b': ['a', 'b', 'c']}) + >>> d['b'] + List(['a', 'b', 'c']) + +### Assignments and deletions return new copies. + +Methods: `set(key, value)`, `delete(key)` + + >>> d2 = d.set('c', 456) + >>> d2 + Dict({'a': 123, 'b': ['a', 'b', 'c'], 'c': 456}) + >>> d3 = d2.delete('a') + >>> d3 + Dict({'b': ['a', 'b', 'c'], 'c': 456}) + +### Standard assignments and deletions fail. + + >>> d['z'] = 123 + TypeError: 'Dict' object doesn't support item assignment + >>> del(d['c']) + TypeError: 'Dict' object doesn't support item deletion + +### Nested lookups. + +Method: `get_in(keys, default=None)` + + >>> d['b'][-1] + 'c' + >>> d['b'][5] + IndexError: list index out of range + >>> d.get_in(['b', -1]) + 'c' + >>> d.get_in(['b', 5]) + None + +### Nested assignments and deletions. + +Methods: `set_in(keys, value)`, `delete_in(keys)` + + >>> d2 = d.set_in(['b', 1], 'xxx') + >>> d2 + Dict({'a': 123, 'b': ['a', 'xxx', 'c']}) + >>> d3 = d2.delete_in(['b', 0]) + >>> d3 + Dict({'a': 123, 'b': ['xxx', 'c']}) + +### Equality works against standard types. + + >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3}) + >>> d == {'a': 1, 'b': 2, 'c': 3} + True + +### Objects are hashable. + + >>> hash(d) + 277752239 + +### Shortcuts for switching between mutable and immutable types. + +Functions: `to_mutable(instance)`, `to_immutable(value)` + + >>> value = itypes.to_mutable(d) + >>> value + {'a': 123, 'b': ['a', 'b', 'c']} + >>> itypes.to_immutable(value) + Dict({'a': 123, 'b': ['a', 'b', 'c']}) + +### Subclassing. + +Only private attribute names may be set on instances. Use `@property` for attribute access. + +Define a `.clone(self, data)` method if objects have additional state. + +Example: + + class Configuration(itypes.Dict): + def __init__(self, title, *args, **kwargs): + self._title = title + super(Configuration, self).__init__(*args, **kwargs) + + @property + def title(self): + return self._title + + def clone(self, data): + return Configuration(self._title, data) + +Using the custom class: + + >>> config = Configuration('worker-process', {'hostname': 'example.com', 'dynos': 4}) + >>> config.title + 'worker-process' + >>> new = config.set('dynos', 2) + >>> new + Configuration({'dynos': 2, 'hostname': 'example.com'}) + >>> new.title + 'worker-process' + +### Custom immutable objects. + +Subclass `itypes.Object` for an object that prevents setting public attributes. + + >>> class Custom(itypes.Object): + ... pass + +Only private attribute names may be set on instances. Use `@property` for attribute access. + + >>> class Document(itypes.Object): + ... def __init__(self, title, content): + ... self._title = title + ... self._content = title + ... @property + ... def title(self): + ... return self._title + ... @property + ... def content(self): + ... return self._content + +Using immutable objects: + + >>> doc = Document(title='Immutability', content='For simplicity') + >>> doc.title + 'Immutability' + >>> doc.title = 'Changed' + TypeError: 'Document' object doesn't support property assignment. + + + + +%prep +%autosetup -n itypes-1.2.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-itypes -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu Mar 09 2023 Python_Bot <Python_Bot@openeuler.org> - 1.2.0-1 +- Package Spec generated @@ -0,0 +1 @@ +8c8e98875d885e87074d071c447cd9c4 itypes-1.2.0.tar.gz |