scaevola 1.1.1__tar.gz → 1.1.3__tar.gz
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.
- {scaevola-1.1.1/src/scaevola.egg-info → scaevola-1.1.3}/PKG-INFO +2 -1
- {scaevola-1.1.1 → scaevola-1.1.3}/pyproject.toml +5 -3
- scaevola-1.1.3/src/scaevola/core/__init__.py +68 -0
- scaevola-1.1.3/src/scaevola/core/cfg.toml +48 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/tests/test_slots_Scaevola.py +0 -2
- {scaevola-1.1.1 → scaevola-1.1.3/src/scaevola.egg-info}/PKG-INFO +2 -1
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola.egg-info/SOURCES.txt +1 -0
- scaevola-1.1.3/src/scaevola.egg-info/requires.txt +1 -0
- scaevola-1.1.1/src/scaevola/core/__init__.py +0 -85
- scaevola-1.1.1/src/scaevola/core/cfg.toml +0 -20
- {scaevola-1.1.1 → scaevola-1.1.3}/LICENSE.txt +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/MANIFEST.in +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/README.rst +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/setup.cfg +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/__init__.py +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/tests/__init__.py +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/tests/test_doc.py +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/tests/test_op.py +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola/tests/test_slots_auto.py +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola.egg-info/dependency_links.txt +0 -0
- {scaevola-1.1.1 → scaevola-1.1.3}/src/scaevola.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scaevola
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
4
4
|
Summary: This project provides a class with preset right handed magic methods.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -39,6 +39,7 @@ Classifier: Typing :: Typed
|
|
|
39
39
|
Requires-Python: >=3.11
|
|
40
40
|
Description-Content-Type: text/x-rst
|
|
41
41
|
License-File: LICENSE.txt
|
|
42
|
+
Requires-Dist: setdoc<2,>=1.2.8
|
|
42
43
|
Dynamic: license-file
|
|
43
44
|
|
|
44
45
|
========
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
3
|
requires = [
|
|
4
|
-
"setuptools>=
|
|
4
|
+
"setuptools>=64.0",
|
|
5
5
|
]
|
|
6
6
|
|
|
7
7
|
[project]
|
|
@@ -18,13 +18,15 @@ classifiers = [
|
|
|
18
18
|
"Programming Language :: Python :: 3 :: Only",
|
|
19
19
|
"Typing :: Typed",
|
|
20
20
|
]
|
|
21
|
-
dependencies = [
|
|
21
|
+
dependencies = [
|
|
22
|
+
"setdoc>=1.2.8,<2",
|
|
23
|
+
]
|
|
22
24
|
description = "This project provides a class with preset right handed magic methods."
|
|
23
25
|
keywords = []
|
|
24
26
|
name = "scaevola"
|
|
25
27
|
readme = "README.rst"
|
|
26
28
|
requires-python = ">=3.11"
|
|
27
|
-
version = "1.1.
|
|
29
|
+
version = "1.1.3"
|
|
28
30
|
|
|
29
31
|
[project.license]
|
|
30
32
|
file = "LICENSE.txt"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import builtins
|
|
2
|
+
import enum
|
|
3
|
+
import functools
|
|
4
|
+
import operator
|
|
5
|
+
import tomllib
|
|
6
|
+
import types
|
|
7
|
+
from importlib import resources
|
|
8
|
+
from typing import *
|
|
9
|
+
|
|
10
|
+
import setdoc
|
|
11
|
+
|
|
12
|
+
__all__ = ["Scaevola", "auto", "getfuncnames", "makefunc"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Util(enum.Enum):
|
|
16
|
+
"This enum provides a singleton."
|
|
17
|
+
|
|
18
|
+
util = None
|
|
19
|
+
|
|
20
|
+
@functools.cached_property
|
|
21
|
+
def data(self: Self) -> dict:
|
|
22
|
+
"This cached property holds the cfg data."
|
|
23
|
+
text: str
|
|
24
|
+
text = resources.read_text("scaevola.core", "cfg.toml")
|
|
25
|
+
return tomllib.loads(text)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def auto(cls: type) -> type:
|
|
29
|
+
"This decorator implements all the righthand functions."
|
|
30
|
+
name: str
|
|
31
|
+
for name in getfuncnames():
|
|
32
|
+
if name not in cls.__dict__.keys():
|
|
33
|
+
makefunc(cls, name)
|
|
34
|
+
return cls
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def getfuncnames() -> list[str]:
|
|
38
|
+
"This function returns the names of all righthand functions."
|
|
39
|
+
return list(Util.util.data.keys())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def makefunc(cls: type, name: str) -> types.FunctionType:
|
|
43
|
+
"This function implements a certain righthand function."
|
|
44
|
+
funcname: str
|
|
45
|
+
inner: Callable
|
|
46
|
+
module: Any
|
|
47
|
+
funcname = Util.util.data[name]["func"]
|
|
48
|
+
if Util.util.data[name].get("isbuiltin", False):
|
|
49
|
+
module = builtins
|
|
50
|
+
else:
|
|
51
|
+
module = operator
|
|
52
|
+
inner = getattr(module, funcname)
|
|
53
|
+
|
|
54
|
+
def outer(self: Self, other: Any) -> Any:
|
|
55
|
+
"This docstring will be overwritten."
|
|
56
|
+
return inner(type(self)(other), self)
|
|
57
|
+
|
|
58
|
+
outer.__module__ = cls.__module__
|
|
59
|
+
outer.__name__ = name
|
|
60
|
+
outer.__qualname__ = cls.__qualname__ + "." + name
|
|
61
|
+
setdoc.basic(outer)
|
|
62
|
+
setattr(cls, name, outer)
|
|
63
|
+
return outer
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@auto
|
|
67
|
+
class Scaevola:
|
|
68
|
+
__slots__ = ()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[__ge__]
|
|
2
|
+
func = "le"
|
|
3
|
+
|
|
4
|
+
[__gt__]
|
|
5
|
+
func = "lt"
|
|
6
|
+
|
|
7
|
+
[__radd__]
|
|
8
|
+
func = "add"
|
|
9
|
+
|
|
10
|
+
[__rand__]
|
|
11
|
+
func = "and_"
|
|
12
|
+
|
|
13
|
+
[__rdivmod__]
|
|
14
|
+
func = "divmod"
|
|
15
|
+
isbuiltin = true
|
|
16
|
+
|
|
17
|
+
[__rfloordiv__]
|
|
18
|
+
func = "floordiv"
|
|
19
|
+
|
|
20
|
+
[__rlshift__]
|
|
21
|
+
func = "lshift"
|
|
22
|
+
|
|
23
|
+
[__rmatmul__]
|
|
24
|
+
func = "matmul"
|
|
25
|
+
|
|
26
|
+
[__rmod__]
|
|
27
|
+
func = "mod"
|
|
28
|
+
|
|
29
|
+
[__rmul__]
|
|
30
|
+
func = "mul"
|
|
31
|
+
|
|
32
|
+
[__ror__]
|
|
33
|
+
func = "or_"
|
|
34
|
+
|
|
35
|
+
[__rpow__]
|
|
36
|
+
func = "pow"
|
|
37
|
+
|
|
38
|
+
[__rrshift__]
|
|
39
|
+
func = "rshift"
|
|
40
|
+
|
|
41
|
+
[__rsub__]
|
|
42
|
+
func = "sub"
|
|
43
|
+
|
|
44
|
+
[__rtruediv__]
|
|
45
|
+
func = "truediv"
|
|
46
|
+
|
|
47
|
+
[__rxor__]
|
|
48
|
+
func = "xor"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scaevola
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
4
4
|
Summary: This project provides a class with preset right handed magic methods.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -39,6 +39,7 @@ Classifier: Typing :: Typed
|
|
|
39
39
|
Requires-Python: >=3.11
|
|
40
40
|
Description-Content-Type: text/x-rst
|
|
41
41
|
License-File: LICENSE.txt
|
|
42
|
+
Requires-Dist: setdoc<2,>=1.2.8
|
|
42
43
|
Dynamic: license-file
|
|
43
44
|
|
|
44
45
|
========
|
|
@@ -7,6 +7,7 @@ src/scaevola/__init__.py
|
|
|
7
7
|
src/scaevola.egg-info/PKG-INFO
|
|
8
8
|
src/scaevola.egg-info/SOURCES.txt
|
|
9
9
|
src/scaevola.egg-info/dependency_links.txt
|
|
10
|
+
src/scaevola.egg-info/requires.txt
|
|
10
11
|
src/scaevola.egg-info/top_level.txt
|
|
11
12
|
src/scaevola/core/__init__.py
|
|
12
13
|
src/scaevola/core/cfg.toml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
setdoc<2,>=1.2.8
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import enum
|
|
2
|
-
import functools
|
|
3
|
-
import operator
|
|
4
|
-
import tomllib
|
|
5
|
-
import types
|
|
6
|
-
from importlib import resources
|
|
7
|
-
from typing import *
|
|
8
|
-
|
|
9
|
-
__all__ = ["Scaevola", "auto", "getfuncnames", "makefunc"]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class Util(enum.Enum):
|
|
13
|
-
"This enum provides a singleton."
|
|
14
|
-
util = None
|
|
15
|
-
|
|
16
|
-
@functools.cached_property
|
|
17
|
-
def data(self: Self) -> dict:
|
|
18
|
-
"This cached property holds the cfg data."
|
|
19
|
-
text: str = resources.read_text("scaevola.core", "cfg.toml")
|
|
20
|
-
ans: dict = tomllib.loads(text)
|
|
21
|
-
return ans
|
|
22
|
-
|
|
23
|
-
@functools.cached_property
|
|
24
|
-
def funcdata(self: Self) -> dict:
|
|
25
|
-
"This cached property holds the data for easy function making."
|
|
26
|
-
ans: dict = dict()
|
|
27
|
-
name: str
|
|
28
|
-
doc: str
|
|
29
|
-
inner: Callable
|
|
30
|
-
name = "__ge__"
|
|
31
|
-
doc = self.data["docs"]["ge"]
|
|
32
|
-
inner = operator.le
|
|
33
|
-
ans[name] = dict(doc=doc, inner=inner)
|
|
34
|
-
name = "__gt__"
|
|
35
|
-
doc = self.data["docs"]["gt"]
|
|
36
|
-
inner = operator.lt
|
|
37
|
-
ans[name] = dict(doc=doc, inner=inner)
|
|
38
|
-
name = "__rdivmod__"
|
|
39
|
-
doc = self.data["docs"]["rdivmod"]
|
|
40
|
-
inner = divmod
|
|
41
|
-
ans[name] = dict(doc=doc, inner=inner)
|
|
42
|
-
x: Any
|
|
43
|
-
y: Any
|
|
44
|
-
for x, y in self.data["operator"].items():
|
|
45
|
-
name = "__r%s__" % x.rstrip("_")
|
|
46
|
-
doc = self.data["docs"]["operator"] % y
|
|
47
|
-
inner = getattr(operator, x)
|
|
48
|
-
ans[name] = dict(doc=doc, inner=inner)
|
|
49
|
-
ans = dict(sorted(ans.items()))
|
|
50
|
-
return ans
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def auto(cls: type) -> type:
|
|
54
|
-
"This decorator implements all the righthand functions."
|
|
55
|
-
name: str
|
|
56
|
-
for name in getfuncnames():
|
|
57
|
-
if name not in cls.__dict__.keys():
|
|
58
|
-
makefunc(cls, name)
|
|
59
|
-
return cls
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def getfuncnames() -> list[str]:
|
|
63
|
-
"This function returns the names of all righthand functions."
|
|
64
|
-
return list(Util.util.funcdata.keys())
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def makefunc(cls: type, name: str) -> types.FunctionType:
|
|
68
|
-
"This function implements a certain righthand function."
|
|
69
|
-
inner: Callable = Util.util.funcdata[name]["inner"]
|
|
70
|
-
|
|
71
|
-
def outer(self: Self, other: Any) -> Any:
|
|
72
|
-
"This docstring will be overwritten."
|
|
73
|
-
return inner(type(self)(other), self)
|
|
74
|
-
|
|
75
|
-
outer.__doc__ = Util.util.funcdata[name]["doc"]
|
|
76
|
-
outer.__module__ = cls.__module__
|
|
77
|
-
outer.__name__ = name
|
|
78
|
-
outer.__qualname__ = cls.__qualname__ + "." + name
|
|
79
|
-
setattr(cls, name, outer)
|
|
80
|
-
return outer
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
@auto
|
|
84
|
-
class Scaevola:
|
|
85
|
-
pass
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
[docs]
|
|
2
|
-
operator = "This magic method implements other%sself."
|
|
3
|
-
ge = "This magic method implements self>=other."
|
|
4
|
-
gt = "This magic method implements self>other."
|
|
5
|
-
rdivmod = "This magic method implements divmod(other, self)."
|
|
6
|
-
|
|
7
|
-
[operator]
|
|
8
|
-
add = "+"
|
|
9
|
-
and_ = "&"
|
|
10
|
-
floordiv = "//"
|
|
11
|
-
lshift = "<<"
|
|
12
|
-
matmul = "@"
|
|
13
|
-
mod = "%"
|
|
14
|
-
mul = "*"
|
|
15
|
-
or_ = "|"
|
|
16
|
-
pow = "**"
|
|
17
|
-
rshift = ">>"
|
|
18
|
-
sub = "-"
|
|
19
|
-
truediv = "/"
|
|
20
|
-
xor = "^"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|