diff options
author | Josh Blum | 2011-11-07 20:04:06 -0800 |
---|---|---|
committer | Josh Blum | 2011-11-07 20:04:06 -0800 |
commit | d4f209dcfef230e504179a9916c8167fa8d165f4 (patch) | |
tree | df56fe437eaf43de82e5859e97df6dabf02bf8ff /gr-uhd/swig/__init__.py | |
parent | 24d572bc56f265f99b1994cd031df6bd15607ff3 (diff) | |
parent | 24da5f495ca629113ea17f14e764af26a2285e73 (diff) | |
download | gnuradio-d4f209dcfef230e504179a9916c8167fa8d165f4.tar.gz gnuradio-d4f209dcfef230e504179a9916c8167fa8d165f4.tar.bz2 gnuradio-d4f209dcfef230e504179a9916c8167fa8d165f4.zip |
Merge remote-tracking branch 'jblum/uhd_next'
Diffstat (limited to 'gr-uhd/swig/__init__.py')
-rw-r--r-- | gr-uhd/swig/__init__.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 7745b4b79..d098a7b8a 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -57,6 +57,20 @@ def _prepare_uhd_swig(): def __setitem__(self, key, val): self.set(key, val) setattr(uhd_swig, 'device_addr_t', device_addr_t) + #make the streamer args take **kwargs on init + class stream_args_t(uhd_swig.stream_args_t): + def __init__(self, *args, **kwargs): + super(stream_args_t, self).__init__(*args) + for key, val in kwargs.iteritems(): + #for some reason, i cant assign a list in the constructor + #but what i can do is append the elements individually + if key == 'channels': + for v in val: self.channels.append(v) + elif key == 'args': + self.args = device_addr_t(val) + else: setattr(self, key, val) + setattr(uhd_swig, 'stream_args_t', stream_args_t) + #handle general things on all uhd_swig attributes #Install the __str__ and __repr__ handlers if applicable #Create aliases for uhd swig attributes to avoid the "_t" @@ -88,9 +102,14 @@ def _prepare_uhd_swig(): (0, 'device_addr', device_addr), (1, 'io_type', io_type), ): - if len(args) > index: args[index] = cast(args[index]) - if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) - return old_constructor(*args, **kwargs) + try: + if len(args) > index: args[index] = cast(args[index]) + if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + except: pass + #dont pass kwargs, it confuses swig, map into args list: + for key in ('device_addr', 'stream_args', 'io_type', 'num_channels'): + if kwargs.has_key(key): args.append(kwargs[key]) + return old_constructor(*args) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) |