From 474b5dd132eb8a1e47d878786df17dfffb37b077 Mon Sep 17 00:00:00 2001
From: Marcus Müller <mmueller@gnuradio.org>
Date: Sun, 21 Apr 2019 16:37:45 +0200
Subject: modtool: Supply SimpleNamespace for legacy Python

---
 gr-utils/python/modtool/core/base.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'gr-utils/python')

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
-- 
cgit v1.2.3