diff options
Diffstat (limited to 'mpm/python/usrp_mpm/simulator/sample_source.py')
-rw-r--r-- | mpm/python/usrp_mpm/simulator/sample_source.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/simulator/sample_source.py b/mpm/python/usrp_mpm/simulator/sample_source.py index 36278efd8..98fc6ff0b 100644 --- a/mpm/python/usrp_mpm/simulator/sample_source.py +++ b/mpm/python/usrp_mpm/simulator/sample_source.py @@ -7,6 +7,7 @@ This module contains the interface for providing data to a simulator stream and receiving data from a simulator stream. """ +import importlib.util sources = {} sinks = {} @@ -21,6 +22,22 @@ def cli_sink(cls): sinks[cls.__name__] = cls return cls +name_index = 0 +module_lookup = {} +def from_import_path(class_name, import_path): + global name_index + global module_lookup + module = None + if import_path in module_lookup: + module = module_lookup[import_path] + else: + spec = importlib.util.spec_from_file_location("simsample." + str(name_index), import_path) + name_index =+ 1 + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + module_lookup[import_path] = module + return getattr(module, class_name) + class SampleSource: """This class defines the interface of a SampleSource. It provides samples to the simulator which are then sent over the |