-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
231 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "saleyo" | ||
version = "1.1.1" | ||
version = "1.1.2" | ||
description = "Saleyo is a lightwight scalable Python AOP framework, easy to use and integrate." | ||
authors = [{ name = "H2Sxxa", email = "[email protected]" }] | ||
dependencies = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[lint] | ||
select = [ | ||
# pycodestyle | ||
"E", | ||
# Pyflakes | ||
"F", | ||
# pyupgrade | ||
"UP", | ||
# flake8-bugbear | ||
"B", | ||
# flake8-simplify | ||
"SIM", | ||
# isort | ||
"I", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from . import typing as typing | ||
from . import template as template | ||
from . import toolchain as toolchain | ||
from . import typing as typing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
The `decorator` should be used to decorate a class. | ||
""" | ||
|
||
from .ancestor import Ancestor as Ancestor | ||
from .mixin import Mixin as Mixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Any, Generic, Type | ||
|
||
from ..base.toolchain import DefaultToolChain, ToolChain | ||
from ..base.typing import T | ||
|
||
|
||
class Ancestor(Generic[T]): | ||
""" | ||
Ancestor will add the `ancestor_class` to `target.__bases__`. | ||
(Please see `__call__` method) | ||
Please ensure the `target.__bases__` is not `(object,)`, this decorator requires | ||
the target has at least one super class. | ||
If `reverse`, the `argument` will add to the head of `target.__bases__`. | ||
Don't try to use it with external code and `module`, it will crash. | ||
""" | ||
|
||
reverse: bool | ||
target: Type[Any] | ||
toolchain: ToolChain | ||
|
||
def __init__( | ||
self, target: Type[Any], toolchain: ToolChain = DefaultToolChain, reverse=False | ||
) -> None: | ||
self.reverse = reverse | ||
self.target = target | ||
self.toolchain = toolchain | ||
|
||
def __call__(self, ancestor_class: Type[T]) -> Type[T]: | ||
assert self.target.__bases__ != (object,) | ||
|
||
self.toolchain.tool_setattr( | ||
self.target, | ||
"__bases__", | ||
(ancestor_class, *self.toolchain.tool_getattr(self.target, "__bases__")) | ||
if self.reverse | ||
else ( | ||
*self.toolchain.tool_getattr(self.target, "__bases__"), | ||
ancestor_class, | ||
), | ||
) | ||
|
||
return ancestor_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
""" | ||
The `operations` always inner a class and call by `@Mixin` decorator. | ||
""" | ||
|
||
from .accessor import Accessor as Accessor | ||
from .accessor import FunctionAccessor as FunctionAccessor | ||
from .overwrite import OverWrite as OverWrite | ||
from .processor import Processor as Processor | ||
from .accessor import FunctionAccessor as FunctionAccessor | ||
from .hook import Post as Post | ||
from .hook import Pre as Pre | ||
from .intercept import Intercept as Intercept | ||
from .ancestor import Ancestor as Ancestor | ||
from .modify import ReName as ReName | ||
from .modify import Del as Del | ||
from .modify import Alias as Alias | ||
from .modify import Del as Del | ||
from .modify import Insert as Insert | ||
from .hook import Pre as Pre | ||
from .hook import Post as Post | ||
from .modify import ReName as ReName | ||
from .overwrite import OverWrite as OverWrite | ||
from .processor import Processor as Processor |
Oops, something went wrong.