aspyx 1.6.1__py3-none-any.whl → 1.7.0__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.

Potentially problematic release.


This version of aspyx might be problematic. Click here for more details.

@@ -94,7 +94,12 @@ class TypeDescriptor:
94
94
  """
95
95
  This class provides a way to introspect Python classes, their methods, decorators, and type hints.
96
96
  """
97
- # inner class
97
+ # inner classes
98
+
99
+ class ParameterDescriptor:
100
+ def __init__(self, name: str, type: Type):
101
+ self.name = name
102
+ self.type = type
98
103
 
99
104
  class MethodDescriptor:
100
105
  """
@@ -107,12 +112,14 @@ class TypeDescriptor:
107
112
  self.method = method
108
113
  self.decorators: list[DecoratorDescriptor] = Decorators.get(method)
109
114
  self.param_types : list[Type] = []
115
+ self.params: list[TypeDescriptor.ParameterDescriptor] = []
110
116
 
111
117
  type_hints = get_type_hints(method)
112
118
  sig = signature(method)
113
119
 
114
120
  for name, _ in sig.parameters.items():
115
121
  if name != 'self':
122
+ self.params.append(TypeDescriptor.ParameterDescriptor(name, type_hints.get(name)))
116
123
  self.param_types.append(type_hints.get(name, object))
117
124
 
118
125
  self.return_type = type_hints.get('return', None)
aspyx/util/__init__.py CHANGED
@@ -4,11 +4,14 @@ This module provides utility functions.
4
4
  from .stringbuilder import StringBuilder
5
5
  from .logger import Logger
6
6
  from .serialization import TypeSerializer, TypeDeserializer, get_serializer, get_deserializer
7
+ from .copy_on_write_cache import CopyOnWriteCache
7
8
 
8
9
  __all__ = [
9
10
  "StringBuilder",
10
11
  "Logger",
11
12
 
13
+ "CopyOnWriteCache",
14
+
12
15
  "TypeSerializer",
13
16
  "TypeDeserializer",
14
17
  "get_serializer",
@@ -0,0 +1,37 @@
1
+ from typing import TypeVar, Generic, Optional, Callable
2
+
3
+ K = TypeVar("K")
4
+ V = TypeVar("V")
5
+
6
+ class CopyOnWriteCache(Generic[K, V]):
7
+ # constructor
8
+
9
+ def __init__(self, factory: Optional[Callable[[K], V]] = None) -> None:
10
+ self._cache: dict[K, V] = {}
11
+ self._factory = factory
12
+
13
+ # public
14
+
15
+ def get(self, key: K, factory: Optional[Callable[[K], V]] = None) -> Optional[V]:
16
+ value = self._cache.get(key, None)
17
+ if value is None:
18
+ if factory is not None:
19
+ value = factory(key)
20
+ self.put(key, value)
21
+
22
+ elif self._factory is not None:
23
+ value = self._factory(key)
24
+ self.put(key, value)
25
+
26
+ return value
27
+
28
+ def put(self, key: K, value: V) -> None:
29
+ new_cache = self._cache.copy()
30
+ new_cache[key] = value
31
+ self._cache = new_cache
32
+
33
+ def contains(self, key: K) -> bool:
34
+ return key in self._cache
35
+
36
+ def clear(self) -> None:
37
+ self._cache = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aspyx
3
- Version: 1.6.1
3
+ Version: 1.7.0
4
4
  Summary: A DI and AOP library for Python
5
5
  Author-email: Andreas Ernst <andreas.ernst7@gmail.com>
6
6
  License: MIT License
@@ -13,15 +13,16 @@ aspyx/exception/__init__.py,sha256=HfK0kk1Tcw9QaUYgIyMeBFDAIE83pkTrIGYUnoKJXPE,2
13
13
  aspyx/exception/exception_manager.py,sha256=wTxLjSVZ_vYfeo06PKZZS9hbrv_dRCwQotSwowUHLZY,5475
14
14
  aspyx/reflection/__init__.py,sha256=r2sNJrfHDpuqaIYu4fTYsoo046gpgn4VTd7bsS3mQJY,282
15
15
  aspyx/reflection/proxy.py,sha256=1-pgw-TNORFXbV0gowFZqGd-bcWv1ny69bJhq8TLsKs,2761
16
- aspyx/reflection/reflection.py,sha256=BcqXJcMO36Gzq71O4aBsMqPynmBhYLI8V6J7DOInPAM,9142
16
+ aspyx/reflection/reflection.py,sha256=8wBIAVYpCk37tqCkAZ-rBRfAQ4hL0LXxXySrqnAwrEs,9459
17
17
  aspyx/threading/__init__.py,sha256=YWqLk-MOtSg4i3cdzRZUBR25okbbftRRxkaEdfrdMZo,207
18
18
  aspyx/threading/context_local.py,sha256=2I-942IHbR0jCrM1N6Mo56VJwuNWMs2f3R8NJsHygBI,1270
19
19
  aspyx/threading/thread_local.py,sha256=86dNtbA4k2B-rNUUnZgn3_pU0DAojgLrRnh8RL6zf1E,1196
20
- aspyx/util/__init__.py,sha256=B7QK3alguZqExBFGzx-OpHpYeoIc3ZGAL7pJnq8NNvI,352
20
+ aspyx/util/__init__.py,sha256=fiivk3IpXfErFbcVZ1VHDkYQHzSmOysNtKVE9kZFbvU,427
21
+ aspyx/util/copy_on_write_cache.py,sha256=8D4m-9JH0771kNS852SsXrLjPkbINQispgpqiMhM6EE,999
21
22
  aspyx/util/logger.py,sha256=Hti5JyajdPXlf_1jvVT3e6Gf9eLyAsIVJRdNBMahbJs,608
22
23
  aspyx/util/serialization.py,sha256=BRsg-2S7E3IukJqxZGm7FvjTvV5d6rcyrpJT3aKoVmM,4252
23
24
  aspyx/util/stringbuilder.py,sha256=a-0T4YEXSJFUuQ3ztKN1ZPARkh8dIGMSkNEEJHRN7dc,856
24
- aspyx-1.6.1.dist-info/METADATA,sha256=H7d-mtHxb57xtVyxbvcz2385TvqslMxGHXzCtbDxdk8,26017
25
- aspyx-1.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- aspyx-1.6.1.dist-info/licenses/LICENSE,sha256=n4jfx_MNj7cBtPhhI7MCoB_K35cj1icP9yJ4Rh4vlvY,1070
27
- aspyx-1.6.1.dist-info/RECORD,,
25
+ aspyx-1.7.0.dist-info/METADATA,sha256=3_YfSrqx-JzAtXEvp11HyoD-qI5GX1jNv3ENSYg6sXc,26017
26
+ aspyx-1.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ aspyx-1.7.0.dist-info/licenses/LICENSE,sha256=n4jfx_MNj7cBtPhhI7MCoB_K35cj1icP9yJ4Rh4vlvY,1070
28
+ aspyx-1.7.0.dist-info/RECORD,,
File without changes