diff options
author | Xiretza <xiretza@xiretza.xyz> | 2021-02-10 19:17:23 +0100 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-02-10 21:36:22 +0100 |
commit | d52693df5bc7480c3917b7248f8602f2942aeab7 (patch) | |
tree | 6404e02d6f053a6b53c561c6b60a6a54152a9e63 /pyGHDL/libghdl/_decorator.py | |
parent | 8f563f9df8ad94e44f1bd8eecd91d5611e507cc7 (diff) | |
download | ghdl-d52693df5bc7480c3917b7248f8602f2942aeab7.tar.gz ghdl-d52693df5bc7480c3917b7248f8602f2942aeab7.tar.bz2 ghdl-d52693df5bc7480c3917b7248f8602f2942aeab7.zip |
pyGHDL: format using black
Diffstat (limited to 'pyGHDL/libghdl/_decorator.py')
-rw-r--r-- | pyGHDL/libghdl/_decorator.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/pyGHDL/libghdl/_decorator.py b/pyGHDL/libghdl/_decorator.py index bc4b0df61..f46286ac0 100644 --- a/pyGHDL/libghdl/_decorator.py +++ b/pyGHDL/libghdl/_decorator.py @@ -38,28 +38,29 @@ from pydecor import export @export def EnumLookupTable(cls) -> Callable: - """ - Decorator to precalculate a enum lookup table (LUT) for enum position to - enum literal name. + """ + Decorator to precalculate a enum lookup table (LUT) for enum position to + enum literal name. - .. todo:: Make compatible to chained decorators + .. todo:: Make compatible to chained decorators - :param cls: Enumerator class for which a LUT shall be pre-calculated. - """ - def decorator(func) -> Callable: - def gen() -> List[str]: - d = [e for e in dir(cls) if e[0] != "_"] - res = [None] * len(d) - for e in d: - res[getattr(cls, e)] = e - return res + :param cls: Enumerator class for which a LUT shall be pre-calculated. + """ - __lut = gen() + def decorator(func) -> Callable: + def gen() -> List[str]: + d = [e for e in dir(cls) if e[0] != "_"] + res = [None] * len(d) + for e in d: + res[getattr(cls, e)] = e + return res - def wrapper(id: int) -> str: - # function that replaces the placeholder function - return __lut[id] + __lut = gen() - return wrapper + def wrapper(id: int) -> str: + # function that replaces the placeholder function + return __lut[id] - return decorator + return wrapper + + return decorator |