Index: hivetool =================================================================== --- hivetool (revision 31429) +++ hivetool (arbetskopia) @@ -82,6 +82,23 @@ return 0 +def machine_walk(hive, ih, folderpath): + # Handle parameters and values + for paramname in ih.get_parameters(folderpath): + parampath = folderpath + "/" + paramname + value = ih.get_string(parampath) + print parampath, "=", value + #hive.set_string(parampath, value) + + for subname in ih.get_folders(folderpath): + if subname == "/": + continue + if folderpath != "/": + subname = "/" + subname + subfolder = folderpath + subname + machine_walk(hive, ih, subfolder) + + def imp_walk(hive, ih, folderpath): # Handle parameters and values for paramname in ih.get_parameters(folderpath): @@ -125,6 +142,7 @@ hivetool [options] [type:]parameter[=value] ... -a,--all-entries Print all parameters and values in a folder + -A Like -a, but with machine parseable output -i,--import Import all parameters in specified file -p,--purge Remove parameters in specified file which exists elsewhere -R,--recursive When using -a, ascend folders recursively @@ -152,7 +170,7 @@ def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "a:i:p:Rr:ve:E:x?", + opts, args = getopt.getopt(sys.argv[1:], "a:A:i:p:Rr:ve:E:x?", ["all-entries=", "import=", "purge=", "recursive", "root=", "version", "help", "eval=", "export"]) except getopt.GetoptError: @@ -161,6 +179,7 @@ roothive = DEFAULT_ROOT_HIVE walk_folders = [] + machine_folders = [] imp_files = [] purge_files = [] recursive = 0 @@ -170,6 +189,8 @@ for o, a in opts: if o in ("-a", "--all-entries"): walk_folders.append(a) + if o in ("-A",): + machine_folders.append(a) if o in ("-i", "--import"): imp_files.append(a) if o in ("-p", "--purge"): @@ -235,7 +256,7 @@ errors += handle_param(hive, param) # Walk - for foldername in walk_folders: + for foldername in walk_folders + machine_folders: folder = hive.lookup(foldername) if not folder: print >>sys.stderr, "%s: Folder not found" % foldername @@ -244,9 +265,12 @@ if not isinstance(folder, hiveconf.Folder): print >>sys.stderr, "%s: not a folder" % foldername continue - - folder.walk(recursive) + if foldername in walk_folders: + folder.walk(recursive) + else: + machine_walk(hive, folder, "/") + sys.exit(errors) if __name__ == "__main__":