summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorJosh Blum2011-01-05 20:15:10 -0800
committerJosh Blum2011-01-19 22:24:57 -0800
commit69ae2c9b1eca4c69d9007b146aa54fd1b75fcd28 (patch)
tree054e7413a3d86305423df0bb8745d579feb402d8 /gr-uhd
parentdfcc8cc28d8e5d0ca1de62b1622438be2439ebd1 (diff)
downloadgnuradio-69ae2c9b1eca4c69d9007b146aa54fd1b75fcd28.tar.gz
gnuradio-69ae2c9b1eca4c69d9007b146aa54fd1b75fcd28.tar.bz2
gnuradio-69ae2c9b1eca4c69d9007b146aa54fd1b75fcd28.zip
uhd: make the repr and str installation more generic
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/swig/__init__.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py
index 0991f5b6b..18b5dfefc 100644
--- a/gr-uhd/swig/__init__.py
+++ b/gr-uhd/swig/__init__.py
@@ -27,13 +27,6 @@
from uhd_swig import *
########################################################################
-# Make types with to_string functions printable
-########################################################################
-range_t.__str__ = lambda s: s.to_pp_string().strip()
-meta_range_t.__str__ = lambda s: s.to_pp_string().strip()
-device_addr_t.__str__ = lambda s: s.to_pp_string().strip()
-
-########################################################################
# Add other content from pure-Python modules here
########################################################################
class freq_range_t(meta_range_t): pass #a typedef for the user
@@ -61,9 +54,13 @@ class device_addr_t(device_addr_t, str):
########################################################################
# Create aliases for global attributes to avoid the "_t"
+# Install the __str__ and __repr__ handlers if applicable
########################################################################
for attr in globals().keys():
- if attr.endswith('_t'): globals()[attr[:-2]] = globals()[attr]
+ myobj = globals()[attr]
+ if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip()
+ if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip()
+ if attr.endswith('_t'): globals()[attr[:-2]] = myobj
########################################################################
# Cast constructor args (FIXME swig handle overloads?)