def get_key_values(self, key, dicts=None):
     """Get the value of a key in the dicts or None in case the key does not exist."""
     if dicts==None: dicts=self.dicts
     key_values = []
     for fd in cm.listify(dicts):
         if key in fd:
             key_values.append(fd[key])
         else:
             key_values.append(None)
     return cm.unlistify(key_values)
 def get_dicts(self, key, values=None, dicts=None):
     """Get all dictionaries in dicts that contain the key with a value specified in values. If values==None then
        get all dictionaries in dicts that contain the key.
     """
     if dicts==None:
         dicts=self.dicts
     the_dicts = []
     for fd in cm.listify(dicts):
         if fd not in the_dicts:
             if key in fd:
                 if values==None:
                    the_dicts.append(fd)
                 elif fd[key] in cm.listify(values):
                    the_dicts.append(fd)
     return cm.unlistify(the_dicts)
示例#3
0
 def get_dicts(self, key, values=None, dicts=None):
     """Get all dictionaries in dicts that contain the key with a value specified in values. If values==None then
        get all dictionaries in dicts that contain the key.
     """
     if dicts == None:
         dicts = self.dicts
     the_dicts = []
     for fd in cm.listify(dicts):
         if fd not in the_dicts:
             if key in fd:
                 if values == None:
                     the_dicts.append(fd)
                 elif fd[key] in cm.listify(values):
                     the_dicts.append(fd)
     return cm.unlistify(the_dicts)
示例#4
0
 def get_key_values(self, key, dicts=None, must_exist=False):
     """Get the value of a key in the dicts, or None in case the key does not exist, or exit if the key must exist.
        If no dicts are specified then default to the self.dicts of the object.
     """
     if dicts == None: dicts = self.dicts
     key_values = []
     for fd in cm.listify(dicts):
         if key in fd:
             key_values.append(fd[key])
         elif must_exist:
             sys.exit(
                 'Error : Key %s does not exist in the dictionary:\n%s.' %
                 (key, fd))
         else:
             key_values.append(None)
     return cm.unlistify(key_values)
示例#5
0
 def get_lib_build_dirs(self, build_type, lib_dicts=None):
     """Get the subdirectories within the central tool build directory for all HDL libraries in the specified list of lib_dicts.
     
     The build_type can be:
         'sim'   uses the 'tool_name_sim'   key in the self.tool_dict
         'synth' uses the 'tool_name_synth' key in the self.tool_dict
         
     The build dir key value must be an absolute directory path. The lib build dir consists of
         - the absolute path to the central main build directory
         - the tool_name_key value as subdirectory
         - the library name as library subdirectory
     """
     if lib_dicts==None: lib_dicts=self.libs.dicts
     build_maindir, build_toolset_dir, build_tooldir = self.get_tool_build_dir(build_type)
     build_dirs = []
     for lib_dict in cm.listify(lib_dicts):
         lib_name = lib_dict['hdl_lib_name']
         build_dirs.append(os.path.join(build_maindir, build_toolset_dir, build_tooldir, lib_name))  # central build main directory with subdirectory per library
     return cm.unlistify(build_dirs)