diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-15 03:30:54 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-15 03:30:54 +0000 |
commit | c193020a012d1ce436b43261d2c184600d13b9f5 (patch) | |
tree | e2c585079ffcd11c09f6c0feab7808447ccbcef7 | |
parent | 1e9a0e9a3ca4d7605634be7b6e1b2c89c7f4411a (diff) |
automatic import of python-iterators
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-iterators.spec | 315 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 317 insertions, 0 deletions
@@ -0,0 +1 @@ +/iterators-0.2.0.tar.gz diff --git a/python-iterators.spec b/python-iterators.spec new file mode 100644 index 0000000..80ea5c7 --- /dev/null +++ b/python-iterators.spec @@ -0,0 +1,315 @@ +%global _empty_manifest_terminate_build 0 +Name: python-iterators +Version: 0.2.0 +Release: 1 +Summary: Iterator utility classes and functions +License: MIT License +URL: https://github.com/leangaurav/pypi_iterator +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/02/c4/135b5bdb9f14f728fe1274361b336f77c5f1606af9a5622a765fe75f5fa0/iterators-0.2.0.tar.gz +BuildArch: noarch + + +%description + + +Available at [PyPi](https://pypi.org/project/iterators/) + +Provides a wrapper class TimeoutIterator to add timeout feature to normal iterators + +### Installation: + + pip install iterators + + +See help of TimeoutIterator for all the features. Check tests for examples on how to use TimeoutIterator. +See example tests below for basic usage + +### Example: + +1. TimeoutIterator works like normal iterator: + + ``` + from iterators import TimeoutIterator + + def iter_simple(): + yield 1 + yield 2 + + def test_normal_iteration(self): + i = iter_simple() + it = TimeoutIterator(i) + + self.assertEqual(next(it), 1) + self.assertEqual(next(it), 2) + + self.assertRaises(StopIteration, next, it) + self.assertRaises(StopIteration, next, it) + ``` + +1. When timeout is needed, use like this + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_fixed_timeout(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 2) + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +1. Dynamic timeout adjustment + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_timeout_update(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + it.set_timeout(0.3) + self.assertEqual(next(it), 2) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +### Run unit tests locally: + python -m unittest discover tests + + +%package -n python3-iterators +Summary: Iterator utility classes and functions +Provides: python-iterators +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-iterators + + +Available at [PyPi](https://pypi.org/project/iterators/) + +Provides a wrapper class TimeoutIterator to add timeout feature to normal iterators + +### Installation: + + pip install iterators + + +See help of TimeoutIterator for all the features. Check tests for examples on how to use TimeoutIterator. +See example tests below for basic usage + +### Example: + +1. TimeoutIterator works like normal iterator: + + ``` + from iterators import TimeoutIterator + + def iter_simple(): + yield 1 + yield 2 + + def test_normal_iteration(self): + i = iter_simple() + it = TimeoutIterator(i) + + self.assertEqual(next(it), 1) + self.assertEqual(next(it), 2) + + self.assertRaises(StopIteration, next, it) + self.assertRaises(StopIteration, next, it) + ``` + +1. When timeout is needed, use like this + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_fixed_timeout(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 2) + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +1. Dynamic timeout adjustment + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_timeout_update(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + it.set_timeout(0.3) + self.assertEqual(next(it), 2) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +### Run unit tests locally: + python -m unittest discover tests + + +%package help +Summary: Development documents and examples for iterators +Provides: python3-iterators-doc +%description help + + +Available at [PyPi](https://pypi.org/project/iterators/) + +Provides a wrapper class TimeoutIterator to add timeout feature to normal iterators + +### Installation: + + pip install iterators + + +See help of TimeoutIterator for all the features. Check tests for examples on how to use TimeoutIterator. +See example tests below for basic usage + +### Example: + +1. TimeoutIterator works like normal iterator: + + ``` + from iterators import TimeoutIterator + + def iter_simple(): + yield 1 + yield 2 + + def test_normal_iteration(self): + i = iter_simple() + it = TimeoutIterator(i) + + self.assertEqual(next(it), 1) + self.assertEqual(next(it), 2) + + self.assertRaises(StopIteration, next, it) + self.assertRaises(StopIteration, next, it) + ``` + +1. When timeout is needed, use like this + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_fixed_timeout(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 2) + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +1. Dynamic timeout adjustment + ``` + def iter_with_sleep(): + yield 1 + time.sleep(0.6) + yield 2 + time.sleep(0.4) + yield 3 + + def test_timeout_update(self): + i = iter_with_sleep() + it = TimeoutIterator(i, timeout=0.5) + self.assertEqual(next(it), 1) + self.assertEqual(next(it), it.get_sentinel()) + + it.set_timeout(0.3) + self.assertEqual(next(it), 2) + self.assertEqual(next(it), it.get_sentinel()) + + self.assertEqual(next(it), 3) + self.assertRaises(StopIteration, next, it) + ``` + +### Run unit tests locally: + python -m unittest discover tests + + +%prep +%autosetup -n iterators-0.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-iterators -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.0-1 +- Package Spec generated @@ -0,0 +1 @@ +7b0bb7e8281202cb5f5e44462c4d37ce iterators-0.2.0.tar.gz |