diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2019-04-21 16:37:45 +0200 |
---|---|---|
committer | Marcus Müller <mmueller@gnuradio.org> | 2019-04-21 17:48:55 +0200 |
commit | 474b5dd132eb8a1e47d878786df17dfffb37b077 (patch) | |
tree | 692f3a7a2edf756167980bf56e46654bc3e21114 /gr-utils/python | |
parent | ee1bef43e92a3d517a3310848c9eebaf18dfa329 (diff) |
modtool: Supply SimpleNamespace for legacy Python
Diffstat (limited to 'gr-utils/python')
-rw-r--r-- | gr-utils/python/modtool/core/base.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gr-utils/python/modtool/core/base.py b/gr-utils/python/modtool/core/base.py index f47fdd5ce6..b9009f4891 100644 --- a/gr-utils/python/modtool/core/base.py +++ b/gr-utils/python/modtool/core/base.py @@ -29,7 +29,22 @@ import re import glob import logging import itertools -from types import SimpleNamespace + +try: + from types import SimpleNamespace +except: + # Py2.7 doesn't have SimpleNamespace, soooo use what Py3 docs say is roughly equivalent + class SimpleNamespace: + def __init__(self, **kwargs): + self.__dict__.update(kwargs) + + def __repr__(self): + keys = sorted(self.__dict__) + items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys) + return "{}({})".format(type(self).__name__, ", ".join(items)) + + def __eq__(self, other): + return self.__dict__ == other.__dict__ from gnuradio import gr from ..tools import get_modname, SCMRepoFactory |