Revision 81d3460c gr-uhd/swig/__init__.py

b/gr-uhd/swig/__init__.py
22 22
# The presence of this file turns this directory into a Python package
23 23

24 24
########################################################################
25
# Create aliases for uhd swig attributes to avoid the "_t"
26
# Install the __str__ and __repr__ handlers if applicable
27
########################################################################
28
import uhd_swig
29
for attr in dir(uhd_swig):
30
    myobj = getattr(uhd_swig, attr)
31
    if hasattr(myobj, 'to_string'):    myobj.__repr__ = lambda s: s.to_string().strip()
32
    if hasattr(myobj, 'to_pp_string'): myobj.__str__  = lambda s: s.to_pp_string().strip()
33
    if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj)
34

35
########################################################################
25 36
# Add SWIG generated code to this namespace
26 37
########################################################################
27 38
from uhd_swig import *
......
53 64
    def __setitem__(self, key, val): self.set(key, val)
54 65

55 66
########################################################################
56
# Create aliases for global attributes to avoid the "_t"
57
# Install the __str__ and __repr__ handlers if applicable
58
########################################################################
59
for attr in globals().keys():
60
    myobj = globals()[attr]
61
    if hasattr(myobj, 'to_string'):    myobj.__repr__ = lambda s: s.to_string().strip()
62
    if hasattr(myobj, 'to_pp_string'): myobj.__str__  = lambda s: s.to_pp_string().strip()
63
    if attr.endswith('_t'): globals()[attr[:-2]] = myobj
64

65
########################################################################
66 67
# Cast constructor args (FIXME swig handle overloads?)
67 68
########################################################################
68 69
for attr in (

Also available in: Unified diff