diff --git a/tools/oneclick/prestudy/YAML/args_demo.py b/tools/oneclick/prestudy/YAML/args_demo.py index 0aec21b1cc2da44545bebf4aceda9c3ac7d5e8d4..8fea23933f9483569ffd1068aeabe3d448d19db1 100755 --- a/tools/oneclick/prestudy/YAML/args_demo.py +++ b/tools/oneclick/prestudy/YAML/args_demo.py @@ -51,17 +51,21 @@ def show_overview(filename): """ show overview of loaded file """ try: config = yaml.load(open(filename, "r")) - name = list(config.keys())[0] + name = config['hdl_library_name'] print(name) - settings = config[name] + #settings = config[name] if '.system.yaml' in filename: system = System(filename) system.show_overview() elif '.peripheral.yaml' in filename: - peripheral = Peripheral(filename) - peripheral.eval_peripheral() - peripheral.show_overview() + logger.info("Load peripheral(s) from '%s'", filename) + library_config = yaml.load(open(filename, 'r')) + for peripheral_config in library_config['peripherals']: + peripheral = Peripheral(peripheral_config) + logger.info(" read peripheral '%s'" % peripheral.component_name()) + peripheral.eval_peripheral() + peripheral.show_overview() except IOError: logger.error("config file '{}' does not exist".format(filename)) diff --git a/tools/oneclick/prestudy/YAML/py_args_lib/peripheral.py b/tools/oneclick/prestudy/YAML/py_args_lib/peripheral.py index e4dda356de41831820293137c4fee475dcad9374..06f342b2001afbf846108c8f232b41a00be2ac29 100755 --- a/tools/oneclick/prestudy/YAML/py_args_lib/peripheral.py +++ b/tools/oneclick/prestudy/YAML/py_args_lib/peripheral.py @@ -498,36 +498,40 @@ class Peripheral(BaseObject): class PeripheralLibrary(object): """ List of all information for peripheral config files in the root dir """ - def __init__(self, root_dir, file_extension='.peripheral.yaml'): + def __init__(self, root_dir=None, file_extension='.peripheral.yaml'): """Store the dictionaries from all file_name files in root_dir.""" self.root_dir = root_dir # all peripheral files have the same double file extension ".peripheral.yaml" self.file_extension = file_extension self.file_path_names = [] - for root, dirs, files in os.walk(self.root_dir, topdown=False): - for name in files: - if self.file_extension in name: - self.file_path_names.append(os.path.join(root, name)) - - # list of peripheral configurations that are read from the available peripheral files - self.peripherals = self.read_all_peripheral_files() + self.peripherals = {} + if root_dir is not None: + for root, dirs, files in os.walk(self.root_dir, topdown=False): + for name in files: + if self.file_extension in name: + self.file_path_names.append(os.path.join(root, name)) + + # list of peripheral configurations that are read from the available peripheral files + self.read_all_peripheral_files() + #print(self.peripherals) self.nof_peripherals = len(self.peripherals) # number of peripherals - #print(self.peripherals) def read_all_peripheral_files(self, file_path_names=None): """Read the peripheral information from all peripheral files that were found in the root_dir tree.""" - peripherals = {} + self.peripherals = {} if file_path_names is None: file_path_names = self.file_path_names - for fpn in self.file_path_names: + for fpn in file_path_names: logger.info("Load peripheral(s) from '%s'", fpn) library_config = yaml.load(open(fpn, 'r')) for peripheral_config in library_config['peripherals']: peripheral = deepcopy(Peripheral(peripheral_config)) logger.info(" read peripheral '%s'" % peripheral.component_name()) - peripherals[peripheral.component_name()] = peripheral - return peripherals + self.peripherals[peripheral.component_name()] = peripheral + + self.nof_peripherals = len(self.peripherals) # number of peripherals + return def find_peripheral(self, name, peripheral_library=None): """ find peripheral in peripheral_library and return it