diff options
| author | whitespace <nobody@nobody> | 2020-10-07 17:22:26 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@nvidia.com> | 2020-10-07 17:22:26 -0400 |
| commit | 701a01920eee5431d2052aad92aefbdf50ac2139 (patch) | |
| tree | 2bf2339327241f59593b9583b060ebb347db1cea /tests/helpers/python/frrsix.py | |
| parent | bd407b54d26981f30a95bc316ea2ed965d070c53 (diff) | |
*: reformat python files
We are now using black.
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'tests/helpers/python/frrsix.py')
| -rw-r--r-- | tests/helpers/python/frrsix.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/helpers/python/frrsix.py b/tests/helpers/python/frrsix.py index 91714f0c67..df737d92ef 100644 --- a/tests/helpers/python/frrsix.py +++ b/tests/helpers/python/frrsix.py @@ -29,24 +29,29 @@ import sys PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 + def add_metaclass(metaclass): """Class decorator for creating a class with a metaclass.""" + def wrapper(cls): orig_vars = cls.__dict__.copy() - slots = orig_vars.get('__slots__') + slots = orig_vars.get("__slots__") if slots is not None: if isinstance(slots, str): slots = [slots] for slots_var in slots: orig_vars.pop(slots_var) - orig_vars.pop('__dict__', None) - orig_vars.pop('__weakref__', None) + orig_vars.pop("__dict__", None) + orig_vars.pop("__weakref__", None) return metaclass(cls.__name__, cls.__bases__, orig_vars) + return wrapper + if PY3: import builtins - exec_ = getattr(builtins,'exec') + + exec_ = getattr(builtins, "exec") def reraise(tp, value, tb=None): try: @@ -59,7 +64,9 @@ if PY3: value = None tb = None + else: + def exec_(_code_, _globs_=None, _locs_=None): """Execute code in a namespace.""" if _globs_ is None: @@ -72,9 +79,11 @@ else: _locs_ = _globs_ exec("""exec _code_ in _globs_, _locs_""") - exec_("""def reraise(tp, value, tb=None): + exec_( + """def reraise(tp, value, tb=None): try: raise tp, value, tb finally: tb = None -""") +""" + ) |
