- Switch to pyproject macros.
- No more greedy globs in %files. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pyuca?expand=0&rev=11
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 11 05:57:35 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Switch to pyproject macros.
|
||||
- No more greedy globs in %files.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 18 22:42:45 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- We can finally use %pyunittest macro
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 12 23:31:22 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- Run SPEC file through spec-cleaner
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 4 08:18:19 UTC 2019 - pgajdos@suse.com
|
||||
|
||||
- turn on the testsuite
|
||||
- added sources
|
||||
+ test.py
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 2 07:39:26 UTC 2018 - tchvatal@suse.com
|
||||
|
||||
- Update to 1.2 release:
|
||||
* Unicode 8.0 support
|
||||
* Python3 support
|
||||
- Switch to singlespec
|
||||
- Install license
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 16 07:44:36 UTC 2015 - mcihar@suse.cz
|
||||
|
||||
- Initial packaging
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# spec file for package python-pyuca
|
||||
#
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
|
||||
|
||||
Name: python-pyuca
|
||||
Version: 1.2
|
||||
Release: 0
|
||||
Summary: Python implementation of the Unicode Collation Algorithm
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/jtauber/pyuca
|
||||
Source0: https://files.pythonhosted.org/packages/source/p/pyuca/pyuca-%{version}.tar.gz
|
||||
# https://github.com/jtauber/pyuca/issues/21
|
||||
Source1: https://raw.githubusercontent.com/jtauber/pyuca/master/test.py
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
This is a Python implementation of the Unicode Collation Algorithm (UCA). It
|
||||
passes 100% of the UCA conformances tests for Unicode 6.3.0 with a
|
||||
variable-weighting setting of Non-ignorable.
|
||||
|
||||
%prep
|
||||
%setup -q -n pyuca-%{version}
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%build
|
||||
%pyproject_wheel
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%pyunittest test
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE*
|
||||
%doc README.md
|
||||
%{python_sitelib}/pyuca
|
||||
%{python_sitelib}/pyuca-%{version}.dist-info
|
||||
|
||||
%changelog
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
.osc
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8a382fe74627f08c0d18908c0713ca4a20aad5385f077579e56208beea2893b2
|
||||
size 1398641
|
||||
@@ -0,0 +1,243 @@
|
||||
# coding: utf8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
PYTHON3 = sys.version_info >= (3,)
|
||||
V8_0_0 = sys.version_info >= (3, 5)
|
||||
V10_0_0 = sys.version_info >= (3, 7)
|
||||
|
||||
|
||||
class SmokeTest(unittest.TestCase):
|
||||
|
||||
def test_cafe(self):
|
||||
from pyuca import Collator
|
||||
c = Collator()
|
||||
|
||||
self.assertEqual(
|
||||
sorted(["cafe", "caff", "café"]),
|
||||
["cafe", "caff", "café"]
|
||||
)
|
||||
self.assertEqual(
|
||||
sorted(["cafe", "caff", "café"], key=c.sort_key),
|
||||
["cafe", "café", "caff"]
|
||||
)
|
||||
|
||||
|
||||
class UtilsTest(unittest.TestCase):
|
||||
|
||||
def test_hexstrings2int(self):
|
||||
from pyuca.utils import hexstrings2int
|
||||
self.assertEqual(
|
||||
hexstrings2int(["0000", "0001", "FFFF"]),
|
||||
[0, 1, 65535]
|
||||
)
|
||||
|
||||
def test_int2hexstrings(self):
|
||||
from pyuca.utils import int2hexstrings
|
||||
self.assertEqual(
|
||||
int2hexstrings([0, 1, 65535]),
|
||||
["0000", "0001", "FFFF"]
|
||||
)
|
||||
|
||||
def test_format_collation_elements(self):
|
||||
from pyuca.utils import format_collation_elements
|
||||
self.assertEqual(
|
||||
format_collation_elements([[1, 2, 3], [4, 5]]),
|
||||
"[0001.0002.0003], [0004.0005]"
|
||||
)
|
||||
|
||||
def test_format_collation_elements_none(self):
|
||||
from pyuca.utils import format_collation_elements
|
||||
self.assertEqual(
|
||||
format_collation_elements(None),
|
||||
None
|
||||
)
|
||||
|
||||
def test_format_sort_key(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key([0, 1, 65535]),
|
||||
"| 0001 FFFF"
|
||||
)
|
||||
|
||||
|
||||
class TrieTest(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from pyuca.trie import Trie
|
||||
super(TrieTest, self).__init__(*args, **kwargs)
|
||||
self.t = Trie()
|
||||
|
||||
def test_1(self):
|
||||
self.t.add("foo", "bar")
|
||||
self.assertEqual(self.t.find_prefix("fo"), ("", None, "fo"))
|
||||
self.assertEqual(self.t.find_prefix("foo"), ("foo", "bar", ""))
|
||||
self.assertEqual(self.t.find_prefix("food"), ("foo", "bar", "d"))
|
||||
|
||||
def test_2(self):
|
||||
self.t.add("a", "yes")
|
||||
self.t.add("abc", "yes")
|
||||
self.assertEqual(self.t.find_prefix("abdc"), ("a", "yes", "bdc"))
|
||||
|
||||
|
||||
class FromFullTest(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from pyuca import Collator
|
||||
super(FromFullTest, self).__init__(*args, **kwargs)
|
||||
self.c = Collator()
|
||||
(0, 74, 33, 0, 2, 2, 0)
|
||||
|
||||
@unittest.skipIf(not PYTHON3, "only matches Python 3's UCA version")
|
||||
def test_1(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0332\u0334"),
|
||||
(0x0000, 0x004A, 0x0021, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(not PYTHON3, "only matches Python 3's UCA version")
|
||||
@unittest.skipIf(V8_0_0, "not for UCA version 8.0.0")
|
||||
@unittest.skipIf(V10_0_0, "not for UCA version 10.0.0")
|
||||
def test_2(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0430\u0306\u0334"),
|
||||
(0x1991, 0x0000, 0x0020, 0x004A, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(not PYTHON3, "only matches Python 3's UCA version")
|
||||
@unittest.skipIf(V8_0_0, "not for UCA version 8.0.0")
|
||||
@unittest.skipIf(V10_0_0, "not for UCA version 10.0.0")
|
||||
def test_3(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0FB2\u0F71\u0001\u0F80\u0061"),
|
||||
(0x2571, 0x2587, 0x258A, 0x15EB, 0x0000, 0x0020, 0x0020, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(not PYTHON3, "only matches Python 3's UCA version")
|
||||
@unittest.skipIf(V8_0_0, "not for UCA version 8.0.0")
|
||||
@unittest.skipIf(V10_0_0, "not for UCA version 10.0.0")
|
||||
def test_4(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u4E00\u0021"),
|
||||
(0xFB40, 0xCE00, 0x025D, 0x0000, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(not PYTHON3, "only matches Python 3's UCA version")
|
||||
@unittest.skipIf(V8_0_0, "not for UCA version 8.0.0")
|
||||
@unittest.skipIf(V10_0_0, "not for UCA version 10.0.0")
|
||||
def test_5(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u3400\u0021"),
|
||||
(0xFB80, 0xB400, 0x025D, 0x0000, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(PYTHON3, "only matches the older Python 2's UCA version")
|
||||
def test_1_old(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0332\u0334"),
|
||||
(0x0000, 0x007C, 0x0021, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(PYTHON3, "only matches the older Python 2's UCA version")
|
||||
def test_2_old(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0430\u0306\u0334"),
|
||||
(0x15B0, 0x0000, 0x0020, 0x007C, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(PYTHON3, "only matches the older Python 2's UCA version")
|
||||
def test_3_old(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u0FB2\u0F71\u0001\u0F80\u0061"),
|
||||
(0x205B, 0x206D, 0x2070, 0x120F, 0x0000, 0x0020, 0x0020, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(PYTHON3, "only matches the older Python 2's UCA version")
|
||||
def test_4_old(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u4E00\u0021"),
|
||||
(0xFB40, 0xCE00, 0x026E, 0x0000, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
@unittest.skipIf(PYTHON3, "only matches the older Python 2's UCA version")
|
||||
def test_5_old(self):
|
||||
self.assertEqual(
|
||||
self.c.sort_key("\u3400\u0021"),
|
||||
(0xFB80, 0xB400, 0x026E, 0x0000, 0x0020,
|
||||
0x0020, 0x0000, 0x0002, 0x0002, 0x0000)
|
||||
)
|
||||
|
||||
|
||||
class FromFullTestV8_0_0(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from pyuca.collator import Collator_8_0_0
|
||||
super(FromFullTestV8_0_0, self).__init__(*args, **kwargs)
|
||||
self.c = Collator_8_0_0()
|
||||
|
||||
@unittest.skipIf(not V8_0_0, "only matches UCA version 8.0.0")
|
||||
def test_1(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\u9FD5\u0062")),
|
||||
"FB41 9FD5 1BDB | 0020 0020 | 0002 0002 |",
|
||||
)
|
||||
|
||||
@unittest.skipIf(not V8_0_0, "only matches UCA version 8.0.0")
|
||||
def test_2(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\U0002CEA1\u0062")),
|
||||
"FB85 CEA1 1BDB | 0020 0020 | 0002 0002 |",
|
||||
)
|
||||
|
||||
@unittest.skipIf(not V8_0_0, "only matches UCA version 8.0.0")
|
||||
def test_3(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\U0002B81E\u0062")),
|
||||
"FBC5 B81E 1BDB | 0020 0020 | 0002 0002 |",
|
||||
)
|
||||
|
||||
@unittest.skipIf(not V8_0_0, "only matches UCA version 8.0.0")
|
||||
def test_4(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\U0002CEA2\u0021")),
|
||||
"FBC5 CEA2 025F | 0020 0020 | 0002 0002 |",
|
||||
)
|
||||
|
||||
|
||||
class FromFullTestV10_0_0(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from pyuca.collator import Collator_10_0_0
|
||||
super(FromFullTestV10_0_0, self).__init__(*args, **kwargs)
|
||||
self.c = Collator_10_0_0()
|
||||
|
||||
@unittest.skipIf(not V10_0_0, "only matches UCA version 10.0.0")
|
||||
def test_1(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\u1DF6\u0334")),
|
||||
"| 004A 0033 | 0002 0002 |",
|
||||
)
|
||||
|
||||
@unittest.skipIf(not V10_0_0, "only matches UCA version 10.0.0")
|
||||
def test_2(self):
|
||||
from pyuca.utils import format_sort_key
|
||||
self.assertEqual(
|
||||
format_sort_key(self.c.sort_key("\u9FEA\u0062")),
|
||||
"FB41 9FEA 1CC6 | 0020 0020 | 0002 0002 |",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user