def __read_file(self): # initialize self.path_list = {} self.prog_list = {} self.data_list = {} # read file kvf = KvFile(self.path) if kvf.read() <= 0: print('%s: can\'t open file "%s"' % (self.clsname, self.path)) return -1 self.kvf = kvf # prog list keys = kvf.change_section(self.PROG) keys = kvf.keys() for key in keys: self.prog_list[key] = kvf.get(key) # path list keys = kvf.change_section(self.PATH) keys = kvf.keys() for key in keys: self.path_list[key] = kvf.get(key) # data list keys = kvf.change_section(self.DATA) keys = kvf.keys() for key in keys: self.data_list[key] = kvf.get(key) if self.verbose > 1: for key in self.prog_list.keys(): print('prog: %s = %s' % (key, self.prog_list[key])) for key in self.path_list.keys(): print('path: %s = %s' % (key, self.path_list[key])) for key in self.data_list.keys(): print('data: %s = %s' % (key, self.data_list[key])) self.file_read = True return 0
for n in range(len(dirlist)): if dirlist[n] == srctop: found = True break if not found: error.print('no such directory "%s"' % srctop) topdir = os.sep.join(dirlist[0:n]) if found else None # ---------------------------------------------------------------------- # Read name definitions. # kvf = KvFile(inifile, sep='=') count = kvf.read(dic={'TOPDIR': topdir}) if count < 0: error.print(kvf.error()) keys = sorted(kvf.keys()) if verbose: def fixed(name, width): name += ':' if len(name) < width-1: name += ' ' * (width-len(name)) return name print('names defined (%d):' % count) for key in keys: value = util.pathconv(kvf.get(key), 'unix') if os.path.isfile(value): kind = 'file' elif os.path.isdir(value): kind = 'dir' else: kind = 'name' print(' %s%s (%s)' % (fixed(key, 24), value, kind))