diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-06 09:26:40 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-07 18:56:27 -0800 |
commit | 5b0ae93c8f319bbc367254172719d40f11a0f55b (patch) | |
tree | 3e6decdae54ee512bdce605090e858623813c62b /gr-uhd/swig | |
parent | 24d572bc56f265f99b1994cd031df6bd15607ff3 (diff) |
uhd: backwards compat work which support streamer API
Diffstat (limited to 'gr-uhd/swig')
-rw-r--r-- | gr-uhd/swig/__init__.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 7745b4b797..5c7642a81a 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -57,6 +57,13 @@ 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 streamer_args(uhd_swig.stream_args_t): + def __init__(self, *args, **kwargs): + super(stream_args_t, self).__init__(*args) + for key, val in kwargs.iteritems(): 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" @@ -87,9 +94,12 @@ def _prepare_uhd_swig(): for index, key, cast in ( (0, 'device_addr', device_addr), (1, 'io_type', io_type), + (1, 'stream_args', stream_args), ): - if len(args) > index: args[index] = cast(args[index]) - if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + try: + if len(args) > index: args[index] = cast(args[index]) + if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + except: pass return old_constructor(*args, **kwargs) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) |