found = False 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'
for n in range(len(dirlist)): if dirlist[n] == srctop: found = True break if not found: Error(prog).put('no such directory "%s"' % srctop) ## Absolute path of base directory. 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(prog).put(kvf.error()) ## List of keys in the inifile. keys = sorted(kvf.keys()) if verbose: ## Make fixed length string. # @param name Any string. # @param width Field width (int). # @returns Fixed width string. def fixed(name, width): name += ':' if len(name) < width - 1: name += ' ' * (width - len(name)) return name print('names defined (%d):' % count)
for n in range(len(dirlist)): if dirlist[n] == srctop: found = True break if not found: Error(prog).print('no such directory "%s"' % srctop) ## Absolute path of base directory. 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(prog).print(kvf.error()) ## List of keys in the inifile. keys = sorted(kvf.keys()) if verbose: ## Make fixed length string. # @param name Any string. # @param width Field width (int). # @returns Fixed width string. def fixed(name, width): name += ':' if len(name) < width - 1: name += ' ' * (width - len(name)) return name print('names defined (%d):' % count)
sections = kvf.sections() msg = '%d section(s) defined: %s' % (count, sections) return msg # ---------------------------------------------------------------------- K = KvFile('') print('Test program for class: %s, Ver %s\n' % (K.clsname, K.version)) ## fname = 'test/KvFileTest.ini' print('-- %s --' % fname) kvf = KvFile(fname, verbose=verbose) count = kvf.read() if count < 0: Print(kvf.error()) sys.exit(-1) Print('file: "%s"' % fname) Print(defined_sections(count, kvf)) Print('----') kvf.show(2) print() # keys = ['Springhead2', 'TestRoot', 'OutFile', 'SceneList'] Print('-- all keys are defined --') Print('keys to check: %s' % keys) if kvf.check(keys) == 0: Print('All keys are defined') else: Print('Not all keys are defined !!') print()