diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-10 03:29:32 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-10 03:29:32 +0000 |
commit | aef1481a627eef8285ef84c05ae067a70487b87b (patch) | |
tree | d90ec1f224d0468e2290a652259b98e8720d3dfe | |
parent | 1fbfe2430fd566a7d4d423c9b5d89e13e09e82d8 (diff) |
automatic import of python-slytherinopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-slytherin.spec | 374 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 376 insertions, 0 deletions
@@ -0,0 +1 @@ +/slytherin-2020.11.12.tar.gz diff --git a/python-slytherin.spec b/python-slytherin.spec new file mode 100644 index 0000000..b61f877 --- /dev/null +++ b/python-slytherin.spec @@ -0,0 +1,374 @@ +%global _empty_manifest_terminate_build 0 +Name: python-slytherin +Version: 2020.11.12 +Release: 1 +Summary: Python library of useful but lonely functions and classes +License: MIT +URL: https://github.com/idin/slytherin +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/79/d4/5521525310836b235d1bddaa5ce9f0bcbbb149e42c97e6662d77e49f79dd/slytherin-2020.11.12.tar.gz +BuildArch: noarch + +Requires: python3-base32hex +Requires: python3-geopy + +%description +# Slytherin +Slytherin is a collection of useful but lonely functions and classes +that don't belong to other libraries. + +## Installation +```bash +pip install slytherin +``` + +## Usage + +### `collections` + +#### `cross_lists()` + +```python +from slytherin.collections import cross_lists +list1 = [1, 2, 3] +list2 = [4, 5] +list3 = [[6, 7], [8, 9]] + +cross_lists(list1, list2, list3) +``` +outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + +```python +cross_lists([list1, list2, list3]) +``` +also outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + + +### get_size(obj) +The *get_size()* method calculates the memory footprint of a Python object recursively. + +The *exclude_objects* argument is a list of objects and is optional with the default value +of None. +Any object in the *exclude_objects* list will be excluded from the recursive search. +It can be used to avoid double counting the size when objects point to each other. + +```python +from slytherin import get_size +get_size(obj=[1,2,3], exclude_objects=None) + +import pandas as pd +get_size(obj=pd.DataFrame({'id': range(1000), 'name':['Godric', 'Helga', 'Rowena', 'Salazar']*250})) +``` + +### colour(text, text_colour, style, background_colour) +The *colour()* method can be used to add colour to printing text. + +The colour are integers from 0 to 7: +* black: 0 +* red: 1 +* green: 2 +* yellow: 3 +* blue: 4 +* purple: 5 +* cyan: 6 +* white: 7 + +The *style* argument is an integer between 0 and 5: +* normal: 0 +* bold: 1 +* underline: 2 +* negative1: 3 +* negative2: 5 + +```python +from slytherin import colour +print(colour(text='Hello world!', text_colour=4)) +``` + + + +%package -n python3-slytherin +Summary: Python library of useful but lonely functions and classes +Provides: python-slytherin +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-slytherin +# Slytherin +Slytherin is a collection of useful but lonely functions and classes +that don't belong to other libraries. + +## Installation +```bash +pip install slytherin +``` + +## Usage + +### `collections` + +#### `cross_lists()` + +```python +from slytherin.collections import cross_lists +list1 = [1, 2, 3] +list2 = [4, 5] +list3 = [[6, 7], [8, 9]] + +cross_lists(list1, list2, list3) +``` +outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + +```python +cross_lists([list1, list2, list3]) +``` +also outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + + +### get_size(obj) +The *get_size()* method calculates the memory footprint of a Python object recursively. + +The *exclude_objects* argument is a list of objects and is optional with the default value +of None. +Any object in the *exclude_objects* list will be excluded from the recursive search. +It can be used to avoid double counting the size when objects point to each other. + +```python +from slytherin import get_size +get_size(obj=[1,2,3], exclude_objects=None) + +import pandas as pd +get_size(obj=pd.DataFrame({'id': range(1000), 'name':['Godric', 'Helga', 'Rowena', 'Salazar']*250})) +``` + +### colour(text, text_colour, style, background_colour) +The *colour()* method can be used to add colour to printing text. + +The colour are integers from 0 to 7: +* black: 0 +* red: 1 +* green: 2 +* yellow: 3 +* blue: 4 +* purple: 5 +* cyan: 6 +* white: 7 + +The *style* argument is an integer between 0 and 5: +* normal: 0 +* bold: 1 +* underline: 2 +* negative1: 3 +* negative2: 5 + +```python +from slytherin import colour +print(colour(text='Hello world!', text_colour=4)) +``` + + + +%package help +Summary: Development documents and examples for slytherin +Provides: python3-slytherin-doc +%description help +# Slytherin +Slytherin is a collection of useful but lonely functions and classes +that don't belong to other libraries. + +## Installation +```bash +pip install slytherin +``` + +## Usage + +### `collections` + +#### `cross_lists()` + +```python +from slytherin.collections import cross_lists +list1 = [1, 2, 3] +list2 = [4, 5] +list3 = [[6, 7], [8, 9]] + +cross_lists(list1, list2, list3) +``` +outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + +```python +cross_lists([list1, list2, list3]) +``` +also outputs: +``` +[(1, 4, [6, 7]), + (1, 4, [8, 9]), + (1, 5, [6, 7]), + (1, 5, [8, 9]), + (2, 4, [6, 7]), + (2, 4, [8, 9]), + (2, 5, [6, 7]), + (2, 5, [8, 9]), + (3, 4, [6, 7]), + (3, 4, [8, 9]), + (3, 5, [6, 7]), + (3, 5, [8, 9])] +``` + + +### get_size(obj) +The *get_size()* method calculates the memory footprint of a Python object recursively. + +The *exclude_objects* argument is a list of objects and is optional with the default value +of None. +Any object in the *exclude_objects* list will be excluded from the recursive search. +It can be used to avoid double counting the size when objects point to each other. + +```python +from slytherin import get_size +get_size(obj=[1,2,3], exclude_objects=None) + +import pandas as pd +get_size(obj=pd.DataFrame({'id': range(1000), 'name':['Godric', 'Helga', 'Rowena', 'Salazar']*250})) +``` + +### colour(text, text_colour, style, background_colour) +The *colour()* method can be used to add colour to printing text. + +The colour are integers from 0 to 7: +* black: 0 +* red: 1 +* green: 2 +* yellow: 3 +* blue: 4 +* purple: 5 +* cyan: 6 +* white: 7 + +The *style* argument is an integer between 0 and 5: +* normal: 0 +* bold: 1 +* underline: 2 +* negative1: 3 +* negative2: 5 + +```python +from slytherin import colour +print(colour(text='Hello world!', text_colour=4)) +``` + + + +%prep +%autosetup -n slytherin-2020.11.12 + +%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-slytherin -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 2020.11.12-1 +- Package Spec generated @@ -0,0 +1 @@ +d03bb88eb4eb9d0ad0332608c9538353 slytherin-2020.11.12.tar.gz |