regorator 0.1__py3-none-any.whl → 0.1.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.
regorator/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
+ from . import core, version
1
2
  from .core.main import *
2
- from . import version
@@ -0,0 +1 @@
1
+ from . import main
regorator/core/main.py ADDED
@@ -0,0 +1,87 @@
1
+ import types
2
+
3
+
4
+ def create_registry(desc=""):
5
+ """Create a new registry dictionary."""
6
+ return regdict({}, __doc__=desc)
7
+
8
+
9
+ class regdict(dict):
10
+ """A dict that supports a custom __doc__ attribute."""
11
+
12
+ def __init__(self, *args, __name__=None, __doc__=None, **kwargs):
13
+ super().__init__(*args, **kwargs)
14
+ if __doc__:
15
+ self.__doc__ = __doc__
16
+ if __name__:
17
+ self.__name__ = __name__
18
+
19
+
20
+ def register(name: str, registry, description: str = ""):
21
+ """Decorator to register a function in a given registry."""
22
+ def decorator(func):
23
+ func._correction_name = name
24
+ func._description = description or "No description provided"
25
+ registry[name] = func
26
+ return func
27
+ return decorator
28
+
29
+
30
+ class Register:
31
+ """
32
+ Base class for bricks that require registration.
33
+ """
34
+
35
+ def __init__(self):
36
+ # Each instance gets its own registry
37
+ self.registry = create_registry()
38
+
39
+ def register(cls, name: str, description: str = ""):
40
+ """Class method that wraps the register decorator for the class's registry."""
41
+ def decorator(func):
42
+ return register(name, cls.registry, description)(func)
43
+ return decorator
44
+
45
+ @property
46
+ def available(self):
47
+ return self.registry
48
+
49
+ # @classmethod
50
+ def get(self, name):
51
+ """Retrieve a registered method by name.
52
+ Args:
53
+ name (str): The name of the method.
54
+ Raises:
55
+ KeyError: If the method is not registered.
56
+ """
57
+ meth = self.available.get(
58
+ name, None)
59
+
60
+ if meth is None:
61
+ raise KeyError(
62
+ f"Method '{name}' is not registered.",
63
+ "Check metadata or make sure the method is registered (if custom method).")
64
+ return meth
65
+
66
+ # @classmethod
67
+ def add_method(self, name, how=None):
68
+ """Decorator to add a method dynamically to a class."""
69
+ def decorator(func):
70
+ # Dynamically add the function to the class
71
+ if how == 'classmethod':
72
+ method = classmethod(func)
73
+ elif how == 'static':
74
+ method = func
75
+ else:
76
+ method = types.MethodType(func, self)
77
+ setattr(self, name, method)
78
+ return self
79
+ return decorator
80
+
81
+ def apply(self, data, **kwargs):
82
+ """
83
+ Apply the correction routine to the provided data.
84
+ Must be overridden by subclasses.
85
+ """
86
+ raise NotImplementedError(
87
+ "Each correction module must implement an apply() method.")
regorator/version.py CHANGED
@@ -1,4 +1,4 @@
1
- version = "0.1"
1
+ version = "0.1.1"
2
2
  __version__ = version
3
3
  full_version = version
4
4
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: regorator
3
- Version: 0.1
3
+ Version: 0.1.1
4
4
  Summary: A Python Registry and Decorator System
5
5
  Author-email: Pedro Henrique Coimbra <pedro-henrique.herig-coimbra@inrae.fr>
6
6
  License: EUPL-1.2
@@ -20,4 +20,3 @@ Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Topic :: Other/Nonlisted Topic
23
-
@@ -0,0 +1,8 @@
1
+ regorator/__init__.py,sha256=VA3koMquQPfcKC6a7b8LsZhDkK0pQhRHq00Ja6_xfoo,55
2
+ regorator/version.py,sha256=DV3uSQoffoXzws0pLmLFroOQbeinwXoo-uUF7Pfa2ag,162
3
+ regorator/core/__init__.py,sha256=dkVIvwG8MJYJmauIasz2oyrvcoodV3QY_N1kRhhwgOs,21
4
+ regorator/core/main.py,sha256=s7oqH7V3N4dubKeIbEQtoTJmp1W9VmIzOVRXofG_Fnw,2687
5
+ regorator-0.1.1.dist-info/METADATA,sha256=c0XuA_x0R1IXeESUX6jflFGs1nZ1UpaVveYS303dtUk,1022
6
+ regorator-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
7
+ regorator-0.1.1.dist-info/top_level.txt,sha256=srZ8vy-ArghxY-MAErU3JmFVpXRf9r7hoBSxeZRsnBY,10
8
+ regorator-0.1.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.3)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- regorator/__init__.py,sha256=3ynENL7joMcXhqEKFXoU17R0vvJLDvZyu5baG8mj5Sc,50
2
- regorator/version.py,sha256=POseRB3SzK83fWHtlQZmTDUVs82krdZiP-8m8ubhaeE,160
3
- regorator-0.1.dist-info/METADATA,sha256=-iRIrCq_gD6zxqbYQFOwM3cl4zHhQ5p6DR5lr4I4vV0,1022
4
- regorator-0.1.dist-info/WHEEL,sha256=WnJ8fYhv8N4SYVK2lLYNI6N0kVATA7b0piVUNvqIIJE,91
5
- regorator-0.1.dist-info/top_level.txt,sha256=srZ8vy-ArghxY-MAErU3JmFVpXRf9r7hoBSxeZRsnBY,10
6
- regorator-0.1.dist-info/RECORD,,