Exemplo n.º 1
0
 def load(self, myfilename, recursive = True):
     lines = []
     debug.dprint("USER_CONFIGS: load(); myfilename = %s, recursive = %s, isdir = %s" %(myfilename, str(recursive), str(os.path.isdir(myfilename))))
     if recursive and os.path.isdir(myfilename):
         dirlist = os.listdir(myfilename)
         dirlist.sort()
         debug.dprint("USER_CONFIGS: load(); dirlist = %s" %str(dirlist))
         for f in dirlist:
             if not f.startswith("."):
                 self.load(os.path.join(myfilename, f), recursive)
     else:
         debug.dprint("USER_CONFIGS: load(); not a directory... so load the file: %s" %myfilename)
         lines = read_bash(myfilename)
         self.atomize(lines, myfilename, self.db, self.sources)
Exemplo n.º 2
0
def get_sets_list(filename):
    """Get the package list file and turn it into a tuple
       attributes: pkgs[key = full_name] = [atoms, version]"""
    pkgs = {}
    try:
        _list = read_bash(filename)
    except:
        debug.dprint(
            "PORTAGELIB: get_sets_list(); Failure to locate file: %s" %
            filename)
        return None
    # split the atoms from the pkg name and any trailing attributes if any
    for item in _list:
        parts = split_atom_pkg(item)
        pkgs[parts[0]] = parts[1:]
    return pkgs
Exemplo n.º 3
0
 def reload_file(self, mytype, file):
     """reload a config file due to changes"""
     debug.dprint(" * USER_CONFIGS: reload_file(): mytype = " + mytype +
                  ", file = " + file)
     #return # for now
     # load the file to a temp_db
     temp_db = {}
     temp_sources = {}
     temp_db[mytype] = {}
     temp_sources[mytype] = {}
     lines = []
     lines = read_bash(file)
     if lines:
         self.atomize(lines, file, temp_db, temp_sources)
         temp_sources[mytype][file].sort(cmp)
         new_length = len(temp_sources[mytype][file])
     else:
         new_length = 0
     # get all atoms matching the correct file
     if file in self.sources[mytype]:
         old_file_atoms = self.sources[mytype][file]
         old_file_atoms.sort(cmp)
     else:
         old_file_atoms = []
     old_length = len(old_file_atoms)
     #debug.dprint(" * USER_CONFIGS: reload_file(): old atoms : " +
     #str(old_file_atoms))
     for a in old_file_atoms:
         # delete the old record
         self.db[mytype][a.name].remove(a)
     if file in self.sources[mytype]:
         del self.sources[mytype][file]
     if new_length == 0:
         return
     # update with the new info
     self.sources[mytype][file] = temp_sources[mytype][file]
     for a in temp_sources[mytype][file]:
         # index by name
         if a.name in self.db[mytype]:
             self.db[mytype][a.name].append(a)
         else:
             self.db[mytype][a.name] = [a]