python-injection 0.9.2__py3-none-any.whl → 0.9.3__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 python-injection might be problematic. Click here for more details.
- injection/__init__.pyi +2 -0
- injection/core/module.py +19 -6
- {python_injection-0.9.2.dist-info → python_injection-0.9.3.dist-info}/METADATA +1 -1
- {python_injection-0.9.2.dist-info → python_injection-0.9.3.dist-info}/RECORD +5 -5
- {python_injection-0.9.2.dist-info → python_injection-0.9.3.dist-info}/WHEEL +0 -0
injection/__init__.pyi
CHANGED
|
@@ -2,6 +2,7 @@ from abc import abstractmethod
|
|
|
2
2
|
from collections.abc import Callable
|
|
3
3
|
from contextlib import ContextDecorator
|
|
4
4
|
from enum import StrEnum
|
|
5
|
+
from logging import Logger
|
|
5
6
|
from types import UnionType
|
|
6
7
|
from typing import (
|
|
7
8
|
Any,
|
|
@@ -179,6 +180,7 @@ class Module:
|
|
|
179
180
|
Function to unlock the module by deleting cached instances of singletons.
|
|
180
181
|
"""
|
|
181
182
|
|
|
183
|
+
def add_logger(self, logger: Logger) -> Self: ...
|
|
182
184
|
@classmethod
|
|
183
185
|
def from_name(cls, name: str) -> Self:
|
|
184
186
|
"""
|
injection/core/module.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import inspect
|
|
4
|
-
import logging
|
|
5
4
|
from abc import ABC, abstractmethod
|
|
6
5
|
from collections import OrderedDict
|
|
7
6
|
from collections.abc import (
|
|
@@ -17,6 +16,7 @@ from dataclasses import dataclass, field
|
|
|
17
16
|
from enum import StrEnum
|
|
18
17
|
from functools import partialmethod, singledispatchmethod, update_wrapper
|
|
19
18
|
from inspect import Signature, isclass
|
|
19
|
+
from logging import Logger, getLogger
|
|
20
20
|
from queue import Empty, Queue
|
|
21
21
|
from types import MethodType, UnionType
|
|
22
22
|
from typing import (
|
|
@@ -59,8 +59,6 @@ __all__ = (
|
|
|
59
59
|
"PriorityStr",
|
|
60
60
|
)
|
|
61
61
|
|
|
62
|
-
_logger = logging.getLogger(__name__)
|
|
63
|
-
|
|
64
62
|
"""
|
|
65
63
|
Events
|
|
66
64
|
"""
|
|
@@ -386,6 +384,11 @@ class Module(EventListener, Broker):
|
|
|
386
384
|
init=False,
|
|
387
385
|
repr=False,
|
|
388
386
|
)
|
|
387
|
+
__loggers: list[Logger] = field(
|
|
388
|
+
default_factory=lambda: [getLogger(__name__)],
|
|
389
|
+
init=False,
|
|
390
|
+
repr=False,
|
|
391
|
+
)
|
|
389
392
|
|
|
390
393
|
__instances: ClassVar[dict[str, Module]] = {}
|
|
391
394
|
|
|
@@ -585,6 +588,10 @@ class Module(EventListener, Broker):
|
|
|
585
588
|
|
|
586
589
|
return self
|
|
587
590
|
|
|
591
|
+
def add_logger(self, logger: Logger) -> Self:
|
|
592
|
+
self.__loggers.append(logger)
|
|
593
|
+
return self
|
|
594
|
+
|
|
588
595
|
def add_listener(self, listener: EventListener) -> Self:
|
|
589
596
|
self.__channel.add_listener(listener)
|
|
590
597
|
return self
|
|
@@ -603,7 +610,7 @@ class Module(EventListener, Broker):
|
|
|
603
610
|
|
|
604
611
|
with self.__channel.dispatch(event):
|
|
605
612
|
yield
|
|
606
|
-
|
|
613
|
+
self.__send_debug(event)
|
|
607
614
|
|
|
608
615
|
def __check_locking(self):
|
|
609
616
|
if self.is_locked:
|
|
@@ -619,13 +626,19 @@ class Module(EventListener, Broker):
|
|
|
619
626
|
f"`{module}` can't be found in the modules used by `{self}`."
|
|
620
627
|
) from exc
|
|
621
628
|
|
|
629
|
+
def __send_debug(self, message: object):
|
|
630
|
+
for logger in self.__loggers:
|
|
631
|
+
logger.debug(message)
|
|
632
|
+
|
|
622
633
|
@classmethod
|
|
623
634
|
def from_name(cls, name: str) -> Self:
|
|
624
635
|
with suppress(KeyError):
|
|
625
636
|
return cls.__instances[name]
|
|
626
637
|
|
|
627
|
-
|
|
628
|
-
|
|
638
|
+
with synchronized():
|
|
639
|
+
instance = cls(name)
|
|
640
|
+
cls.__instances[name] = instance
|
|
641
|
+
|
|
629
642
|
return instance
|
|
630
643
|
|
|
631
644
|
@classmethod
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
injection/__init__.py,sha256=LhfwYFMBw6tJ7XA_C353w61OPt4IuQQgs3zIjrwMIz8,654
|
|
2
|
-
injection/__init__.pyi,sha256=
|
|
2
|
+
injection/__init__.pyi,sha256=mpb4pqneX3DLyMfWNmU706FOtNs9MZIy_MXk-ljMY4g,6316
|
|
3
3
|
injection/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
injection/common/event.py,sha256=5Rdb2m3vAMCic8cQAVkStJDbrDrW_lk6kav8wYwmexM,1283
|
|
5
5
|
injection/common/invertible.py,sha256=a-fht4TxMnki-oFFaZrDz52X_LWx0NU60KQlw72pzs4,528
|
|
@@ -8,7 +8,7 @@ injection/common/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
8
8
|
injection/common/tools/threading.py,sha256=HlvP6k_-eZaK8JbB2b9PP171IZVe_0W2oMYsw3ebdKA,187
|
|
9
9
|
injection/common/tools/type.py,sha256=ThM3Z1_gHmsdT4Jp7PlZgJY0lsufc4InPO65485Ugsg,1739
|
|
10
10
|
injection/core/__init__.py,sha256=zuf0ubI2dHnbjn1059eduhS-ACIkkROa6-dhp10krh0,22
|
|
11
|
-
injection/core/module.py,sha256=
|
|
11
|
+
injection/core/module.py,sha256=LlKfQQHBUzlwJzabvmeJOSz0QxjLDZHKXKSk_CYxqlg,22114
|
|
12
12
|
injection/exceptions.py,sha256=RsWWiWwKSMU0vxXQqQSn6CKHLMrGu4SSzYUAy9OJRXk,626
|
|
13
13
|
injection/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
injection/integrations/blacksheep.py,sha256=82P_owhF3FKIJxxalnSic3AJnoOr1mkojkWMefpO6QI,731
|
|
@@ -16,6 +16,6 @@ injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
16
16
|
injection/testing/__init__.py,sha256=cr4e3VnoKbWzkc6uyC03sffT59deKgLN-SKiZjhzooI,880
|
|
17
17
|
injection/testing/__init__.pyi,sha256=_u95cJVHBkt69HUvnu2bbfYWmi7GOH_1qyFyvC1PxBk,518
|
|
18
18
|
injection/utils.py,sha256=a_H6RC6cNWbG1NQ-zvtrlgwnfS5Jfu0X6VJwIUIHlSU,974
|
|
19
|
-
python_injection-0.9.
|
|
20
|
-
python_injection-0.9.
|
|
21
|
-
python_injection-0.9.
|
|
19
|
+
python_injection-0.9.3.dist-info/METADATA,sha256=f2aBg9u9o0X-2ssaejGkj4w6wXIozn5aEmYLWj00aPE,3572
|
|
20
|
+
python_injection-0.9.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
21
|
+
python_injection-0.9.3.dist-info/RECORD,,
|
|
File without changes
|