forked from pool/python-first
Accepting request 682097 from home:jayvdb:coala:python3-bears
- Initial spec for v2.0.1 OBS-URL: https://build.opensuse.org/request/show/682097 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-first?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.osc
|
||||
3
first-2.0.1.tar.gz
Normal file
3
first-2.0.1.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3bb3de3582cb27071cfb514f00ed784dc444b7f96dc21e140de65fe00585c95e
|
||||
size 5325
|
||||
4
python-first.changes
Normal file
4
python-first.changes
Normal file
@@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 6 10:35:25 AM UTC 2019 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Initial spec for v2.0.1
|
||||
57
python-first.spec
Normal file
57
python-first.spec
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# spec file for package python-first
|
||||
#
|
||||
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-first
|
||||
Version: 2.0.1
|
||||
Release: 0
|
||||
Summary: Return the first true value of an iterable
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: http://github.com/hynek/first/
|
||||
Source: https://files.pythonhosted.org/packages/source/f/first/first-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/hynek/first/master/test_first.py
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
Return the first true value of an iterable.
|
||||
|
||||
%prep
|
||||
%setup -q -n first-%{version}
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
||||
%install
|
||||
%python_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%python_expand PYTHONPATH=. $python test_first.py
|
||||
|
||||
%files %{python_files}
|
||||
%doc AUTHORS.rst README.rst
|
||||
%license LICENSE
|
||||
%{python_sitelib}/*
|
||||
|
||||
%changelog
|
||||
40
test_first.py
Normal file
40
test_first.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import unittest
|
||||
from first import first
|
||||
|
||||
|
||||
isbool = lambda x: isinstance(x, bool)
|
||||
isint = lambda x: isinstance(x, int)
|
||||
odd = lambda x: isint(x) and x % 2 != 0
|
||||
even = lambda x: isint(x) and x % 2 == 0
|
||||
is_meaning_of_life = lambda x: x == 42
|
||||
|
||||
|
||||
class TestFirst(unittest.TestCase):
|
||||
def test_empty_iterables(self):
|
||||
s = set()
|
||||
l = []
|
||||
assert first(s) is None
|
||||
assert first(l) is None
|
||||
|
||||
def test_default_value(self):
|
||||
s = set()
|
||||
l = []
|
||||
assert first(s, default=42) == 42
|
||||
assert first(l, default=3.14) == 3.14
|
||||
|
||||
l = [0, False, []]
|
||||
assert first(l, default=3.14) == 3.14
|
||||
|
||||
def test_selection(self):
|
||||
l = [(), 0, False, 3, []]
|
||||
|
||||
assert first(l, default=42) == 3
|
||||
assert first(l, key=isint) == 0
|
||||
assert first(l, key=isbool) is False
|
||||
assert first(l, key=odd) == 3
|
||||
assert first(l, key=even) == 0
|
||||
assert first(l, key=is_meaning_of_life) is None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user