aspyx 1.6.1__tar.gz → 1.7.0__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.

Potentially problematic release.


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

Files changed (41) hide show
  1. {aspyx-1.6.1 → aspyx-1.7.0}/PKG-INFO +1 -1
  2. {aspyx-1.6.1 → aspyx-1.7.0}/pyproject.toml +1 -1
  3. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/reflection/reflection.py +8 -1
  4. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/util/__init__.py +3 -0
  5. aspyx-1.7.0/src/aspyx/util/copy_on_write_cache.py +37 -0
  6. {aspyx-1.6.1 → aspyx-1.7.0}/.gitignore +0 -0
  7. {aspyx-1.6.1 → aspyx-1.7.0}/LICENSE +0 -0
  8. {aspyx-1.6.1 → aspyx-1.7.0}/README.md +0 -0
  9. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/__init__.py +0 -0
  10. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/__init__.py +0 -0
  11. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/aop/__init__.py +0 -0
  12. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/aop/aop.py +0 -0
  13. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/configuration/__init__.py +0 -0
  14. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/configuration/configuration.py +0 -0
  15. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/configuration/env_configuration_source.py +0 -0
  16. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/configuration/yaml_configuration_source.py +0 -0
  17. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/di.py +0 -0
  18. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/threading/__init__.py +0 -0
  19. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/di/threading/synchronized.py +0 -0
  20. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/exception/__init__.py +0 -0
  21. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/exception/exception_manager.py +0 -0
  22. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/reflection/__init__.py +0 -0
  23. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/reflection/proxy.py +0 -0
  24. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/threading/__init__.py +0 -0
  25. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/threading/context_local.py +0 -0
  26. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/threading/thread_local.py +0 -0
  27. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/util/logger.py +0 -0
  28. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/util/serialization.py +0 -0
  29. {aspyx-1.6.1 → aspyx-1.7.0}/src/aspyx/util/stringbuilder.py +0 -0
  30. {aspyx-1.6.1 → aspyx-1.7.0}/tests/config.yaml +0 -0
  31. {aspyx-1.6.1 → aspyx-1.7.0}/tests/config1.yaml +0 -0
  32. {aspyx-1.6.1 → aspyx-1.7.0}/tests/di_import.py +0 -0
  33. {aspyx-1.6.1 → aspyx-1.7.0}/tests/sub_import.py +0 -0
  34. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_aop.py +0 -0
  35. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_configuration.py +0 -0
  36. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_cycle.py +0 -0
  37. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_decorator.py +0 -0
  38. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_di.py +0 -0
  39. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_exception_manager.py +0 -0
  40. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_proxy.py +0 -0
  41. {aspyx-1.6.1 → aspyx-1.7.0}/tests/test_reflection.py +0 -0
@@ -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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aspyx"
3
- version = "1.6.1"
3
+ version = "1.7.0"
4
4
  description = "A DI and AOP library for Python"
5
5
  authors = [{ name = "Andreas Ernst", email = "andreas.ernst7@gmail.com" }]
6
6
  readme = "README.md"
@@ -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)
@@ -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 = {}
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes