aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/libghdl/_decorator.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-01-09 01:10:22 +0100
committertgingold <tgingold@users.noreply.github.com>2021-01-10 10:14:16 +0100
commit936a25178d085c7dbc651ea8889718eb302c012b (patch)
tree20788774623fb7e6c626119bc063f926b776e6a4 /pyGHDL/libghdl/_decorator.py
parentb2a98ec0674c031688ebf479664db6fd4975b428 (diff)
downloadghdl-936a25178d085c7dbc651ea8889718eb302c012b.tar.gz
ghdl-936a25178d085c7dbc651ea8889718eb302c012b.tar.bz2
ghdl-936a25178d085c7dbc651ea8889718eb302c012b.zip
Fixes for Python files.
Diffstat (limited to 'pyGHDL/libghdl/_decorator.py')
-rw-r--r--pyGHDL/libghdl/_decorator.py73
1 files changed, 53 insertions, 20 deletions
diff --git a/pyGHDL/libghdl/_decorator.py b/pyGHDL/libghdl/_decorator.py
index 01863381a..424b72820 100644
--- a/pyGHDL/libghdl/_decorator.py
+++ b/pyGHDL/libghdl/_decorator.py
@@ -1,4 +1,37 @@
-from functools import wraps
+# =============================================================================
+# ____ _ _ ____ _ _ _ _ _ _ _
+# _ __ _ _ / ___| | | | _ \| | | (_) |__ __ _| |__ __| | |
+# | '_ \| | | | | _| |_| | | | | | | | | '_ \ / _` | '_ \ / _` | |
+# | |_) | |_| | |_| | _ | |_| | |___ _| | | |_) | (_| | | | | (_| | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)_|_|_.__/ \__, |_| |_|\__,_|_|
+# |_| |___/ |___/
+# =============================================================================
+# Authors: Patrick Lehmann
+#
+# Package module: Python binding and low-level API for shared library 'libghdl'.
+#
+# License:
+# ============================================================================
+# Copyright (C) 2019-2021 Tristan Gingold
+#
+# GHDL is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#
+# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GHDL; see the file COPYING. If not, write to the Free
+# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# ============================================================================
+#
from typing import Callable, List
from pydecor import export
@@ -6,28 +39,28 @@ 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.
+ """
+ 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
- __lut = gen()
+ __lut = gen()
- def wrapper(id: int) -> str:
- # function that replaces the placeholder function
- return __lut[id]
+ def wrapper(id: int) -> str:
+ # function that replaces the placeholder function
+ return __lut[id]
- return wrapper
+ return wrapper
- return decorator
+ return decorator