cmp3 0.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cmp3/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from cmp3.core import *
2
+ from cmp3.tests import *
cmp3/core/__init__.py ADDED
@@ -0,0 +1,79 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import *
3
+
4
+ import setdoc
5
+
6
+ __all__ = ["CmpABC", "cmp", "cmpDeco"]
7
+
8
+
9
+ def cmp(x: Any, y: Any, /, *, mode: str = "portingguide") -> int:
10
+ "This function returns a value that compares to 0 as x compares to y."
11
+ if mode == "portingguide":
12
+ return (x > y) - (x < y)
13
+ if mode == "poset":
14
+ if (x <= y) and (y <= x):
15
+ return 0
16
+ if (x <= y) and (not y <= x):
17
+ return -1
18
+ if (not x <= y) and (y <= x):
19
+ return 1
20
+ return float("nan")
21
+ raise ValueError
22
+
23
+
24
+ def cmpDeco(cls: type, /) -> type:
25
+ "This decorator enforces the use of __cmp__ upon a class."
26
+
27
+ @setdoc.basic
28
+ def __eq__(self: Self, other: Any) -> Any:
29
+ return self.__cmp__(other).__eq__(0)
30
+
31
+ @setdoc.basic
32
+ def __ge__(self: Self, other: Any) -> Any:
33
+ return self.__cmp__(other).__ge__(0)
34
+
35
+ @setdoc.basic
36
+ def __gt__(self: Self, other: Any) -> Any:
37
+ return self.__cmp__(other).__gt__(0)
38
+
39
+ @setdoc.basic
40
+ def __le__(self: Self, other: Any) -> Any:
41
+ return self.__cmp__(other).__le__(0)
42
+
43
+ @setdoc.basic
44
+ def __lt__(self: Self, other: Any) -> Any:
45
+ return self.__cmp__(other).__lt__(0)
46
+
47
+ @setdoc.basic
48
+ def __ne__(self: Self, other: Any) -> Any:
49
+ return self.__cmp__(other).__ne__(0)
50
+
51
+ func: Callable
52
+ funcs: tuple[Callable, ...]
53
+ funcs = (
54
+ __eq__,
55
+ __ge__,
56
+ __gt__,
57
+ __le__,
58
+ __lt__,
59
+ __ne__,
60
+ )
61
+ for func in funcs:
62
+ setattr(cls, func.__name__, func)
63
+ try:
64
+ func.__module__ = cls.__module__
65
+ except AttributeError:
66
+ pass
67
+ try:
68
+ func.__qualname__ = f"{cls.__qualname__}.{func.__name__}"
69
+ except AttributeError:
70
+ pass
71
+ return cls
72
+
73
+
74
+ @cmpDeco
75
+ class CmpABC(ABC):
76
+ __slots__ = ()
77
+
78
+ @abstractmethod
79
+ def __cmp__(self: Self, other: Any) -> Any: ...
cmp3/tests/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ import unittest
2
+
3
+ __all__ = ["test"]
4
+
5
+
6
+ def test() -> unittest.TextTestRunner:
7
+ "This function runs all the tests."
8
+ loader: unittest.TestLoader
9
+ suite: unittest.TestSuite
10
+ runner: unittest.TextTestRunner
11
+ result: unittest.TextTestResult
12
+ loader = unittest.TestLoader()
13
+ suite = loader.discover(start_dir="cmp3.tests")
14
+ runner = unittest.TextTestRunner()
15
+ result = runner.run(suite)
16
+ return result
@@ -0,0 +1,11 @@
1
+ import unittest
2
+ from typing import *
3
+
4
+
5
+ class Test1984(unittest.TestCase):
6
+ def test_1984(self: Self) -> None:
7
+ self.assertEqual(2 + 2, 4, "Ignorance is Strength")
8
+
9
+
10
+ if __name__ == "__main__":
11
+ unittest.main()
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmp3
3
+ Version: 0.6.1
4
+ Summary: This project updates the concept of __cmp__ for python3.
5
+ Author-email: Johannes <johannes.programming@gmail.com>
6
+ License: The MIT License (MIT)
7
+
8
+ Copyright (c) 2026 Johannes
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Download, https://pypi.org/project/cmp3/#files
28
+ Project-URL: Index, https://pypi.org/project/cmp3/
29
+ Project-URL: Source, https://github.com/johannes-programming/cmp3/
30
+ Project-URL: Website, https://cmp3.johannes-programming.online/
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Natural Language :: English
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3 :: Only
38
+ Classifier: Typing :: Typed
39
+ Requires-Python: >=3.11
40
+ Description-Content-Type: text/x-rst
41
+ License-File: LICENSE.txt
42
+ Requires-Dist: setdoc<2,>=1.2.6
43
+ Dynamic: license-file
44
+
45
+ ====
46
+ cmp3
47
+ ====
48
+
49
+ Visit the website `https://cmp3.johannes-programming.online/ <https://cmp3.johannes-programming.online/>`_ for more information.
@@ -0,0 +1,9 @@
1
+ cmp3/__init__.py,sha256=hxvwX8wZhft-DkMAoU3xz65RMZib8nPQQiAbxba27iQ,49
2
+ cmp3/core/__init__.py,sha256=CHBSj-qY1x9RahRb07dc52HQViYa6g0BTGdwYzIo_go,1939
3
+ cmp3/tests/__init__.py,sha256=HqmxhnTFFqh9Nzl7STV5GeDYqDmhrc9e1TCHssUbC1s,426
4
+ cmp3/tests/test_1984.py,sha256=_ami0cAP8vU0C8RpQhP1tLWnLFGTaeHlOG5O60RVKv8,222
5
+ cmp3-0.6.1.dist-info/licenses/LICENSE.txt,sha256=Jb9jm2E2hEO2LqnWwHeHt4cneyCbnZ1SBte0bgb9qoY,1074
6
+ cmp3-0.6.1.dist-info/METADATA,sha256=4lCA_YQ-mgQTUM3yoMQ4Oa-5S1hZUypM7knfpUO2jZ0,2300
7
+ cmp3-0.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ cmp3-0.6.1.dist-info/top_level.txt,sha256=FzJWsf0Xj_eeRJuFle30ZFjVZs8ahy7oLhYdWx8YkgA,5
9
+ cmp3-0.6.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Johannes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ cmp3