From d52693df5bc7480c3917b7248f8602f2942aeab7 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Wed, 10 Feb 2021 19:17:23 +0100 Subject: pyGHDL: format using black --- pyGHDL/libghdl/_decorator.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'pyGHDL/libghdl/_decorator.py') 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 -- cgit v1.2.3