scaevola 1.1.0__tar.gz → 1.1.2__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.
@@ -0,0 +1 @@
1
+ recursive-include src/scaevola *.toml
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scaevola
3
- Version: 1.1.0
3
+ Version: 1.1.2
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)
@@ -24,7 +24,7 @@ keywords = []
24
24
  name = "scaevola"
25
25
  readme = "README.rst"
26
26
  requires-python = ">=3.11"
27
- version = "1.1.0"
27
+ version = "1.1.2"
28
28
 
29
29
  [project.license]
30
30
  file = "LICENSE.txt"
@@ -1,3 +1,4 @@
1
+ import builtins
1
2
  import enum
2
3
  import functools
3
4
  import operator
@@ -20,35 +21,6 @@ class Util(enum.Enum):
20
21
  ans: dict = tomllib.loads(text)
21
22
  return ans
22
23
 
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
24
 
53
25
  def auto(cls: type) -> type:
54
26
  "This decorator implements all the righthand functions."
@@ -61,18 +33,24 @@ def auto(cls: type) -> type:
61
33
 
62
34
  def getfuncnames() -> list[str]:
63
35
  "This function returns the names of all righthand functions."
64
- return list(Util.util.funcdata.keys())
36
+ return list(Util.util.data.keys())
65
37
 
66
38
 
67
39
  def makefunc(cls: type, name: str) -> types.FunctionType:
68
40
  "This function implements a certain righthand function."
69
- inner: Callable = Util.util.funcdata[name]["inner"]
41
+ funcname: str = Util.util.data[name]["func"]
42
+ module: Any
43
+ if Util.util.data[name].get("isbuiltin", False):
44
+ module = builtins
45
+ else:
46
+ module = operator
47
+ inner: Callable = getattr(module, funcname)
70
48
 
71
49
  def outer(self: Self, other: Any) -> Any:
72
50
  "This docstring will be overwritten."
73
51
  return inner(type(self)(other), self)
74
52
 
75
- outer.__doc__ = Util.util.funcdata[name]["doc"]
53
+ outer.__doc__ = Util.util.data[name]["doc"]
76
54
  outer.__module__ = cls.__module__
77
55
  outer.__name__ = name
78
56
  outer.__qualname__ = cls.__qualname__ + "." + name
@@ -82,4 +60,4 @@ def makefunc(cls: type, name: str) -> types.FunctionType:
82
60
 
83
61
  @auto
84
62
  class Scaevola:
85
- pass
63
+ __slots__ = ()
@@ -0,0 +1,64 @@
1
+ [__ge__]
2
+ doc = "This magic method implements self>=other."
3
+ func = "le"
4
+
5
+ [__gt__]
6
+ doc = "This magic method implements self>other."
7
+ func = "lt"
8
+
9
+ [__radd__]
10
+ doc = "This magic method implements other+self."
11
+ func = "add"
12
+
13
+ [__rand__]
14
+ doc = "This magic method implements other&self."
15
+ func = "and_"
16
+
17
+ [__rdivmod__]
18
+ doc = "This magic method implements divmod(other, self)."
19
+ func = "divmod"
20
+ isbuiltin = true
21
+
22
+ [__rfloordiv__]
23
+ doc = "This magic method implements other//self."
24
+ func = "floordiv"
25
+
26
+ [__rlshift__]
27
+ doc = "This magic method implements other<<self."
28
+ func = "lshift"
29
+
30
+ [__rmatmul__]
31
+ doc = "This magic method implements other@self."
32
+ func = "matmul"
33
+
34
+ [__rmod__]
35
+ doc = "This magic method implements other%self."
36
+ func = "mod"
37
+
38
+ [__rmul__]
39
+ doc = "This magic method implements other*self."
40
+ func = "mul"
41
+
42
+ [__ror__]
43
+ doc = "This magic method implements other|self."
44
+ func = "or_"
45
+
46
+ [__rpow__]
47
+ doc = "This magic method implements other**self."
48
+ func = "pow"
49
+
50
+ [__rrshift__]
51
+ doc = "This magic method implements other>>self."
52
+ func = "rshift"
53
+
54
+ [__rsub__]
55
+ doc = "This magic method implements other-self."
56
+ func = "sub"
57
+
58
+ [__rtruediv__]
59
+ doc = "This magic method implements other/self."
60
+ func = "truediv"
61
+
62
+ [__rxor__]
63
+ doc = "This magic method implements other^self."
64
+ func = "xor"
@@ -17,10 +17,8 @@ class TestSlots(unittest.TestCase):
17
17
  foo: Foo = Foo()
18
18
  foo.x = 4
19
19
  foo.y = 2
20
- foo.z = 0
21
20
  self.assertEqual(foo.x, 4)
22
21
  self.assertEqual(foo.y, 2)
23
- self.assertEqual(foo.z, 0)
24
22
 
25
23
  def test_bar(self: Self) -> None:
26
24
  bar: Bar = Bar()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scaevola
3
- Version: 1.1.0
3
+ Version: 1.1.2
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)
@@ -9,6 +9,7 @@ src/scaevola.egg-info/SOURCES.txt
9
9
  src/scaevola.egg-info/dependency_links.txt
10
10
  src/scaevola.egg-info/top_level.txt
11
11
  src/scaevola/core/__init__.py
12
+ src/scaevola/core/cfg.toml
12
13
  src/scaevola/tests/__init__.py
13
14
  src/scaevola/tests/test_doc.py
14
15
  src/scaevola/tests/test_op.py
File without changes
File without changes
File without changes
File without changes