diff --git a/build/misc/argparse2help.py b/build/misc/argparse2help.py index 82c5ae1d138108aea2d951ef1da45418366cf11c..fd7cf4a5772af648d7ddb83998e9d34ee82f7483 100644 --- a/build/misc/argparse2help.py +++ b/build/misc/argparse2help.py @@ -30,8 +30,11 @@ def write_header(parser, fileName): listOptions = arg.option_strings options = ", ".join(listOptions) spaces = " " * (12 + longestSize - len(options)) - help = help.replace("\n", "\n {}".format(" "*(len(options)) + spaces)) - file.write(" {}{}{}\n".format(options, spaces, help)) + if help != None: + help = help.replace("\n", "\n {}".format(" "*(len(options)) + spaces)) + file.write(" {}{}{}\n".format(options, spaces, help)) + else: + file.write(" {}\n".format(options)) file.write(")RAW\";\n") file.write("#endif\n") file.close() @@ -52,8 +55,11 @@ def write_man(parser, fileName): else: listOptions = arg.option_strings options = "\ ".join(listOptions) - file.write(".IP {}\n".format(options)) - file.write(help.replace("\n","\n.IP\n")+ "\n") + if help != None: + file.write(".IP {}\n".format(options)) + file.write(help.replace("\n","\n.IP\n")+ "\n") + else: + file.write(".IP {}\n\n".format(options)) file.close() if __name__ == "__main__": @@ -66,5 +72,4 @@ if __name__ == "__main__": if (sys.argv[2].partition(".")[2] == "h"): write_header(parser, sys.argv[2]) elif (sys.argv[2].partition(".")[2] == "1"): - write_man(parser, sys.argv[2]) - \ No newline at end of file + write_man(parser, sys.argv[2]) \ No newline at end of file diff --git a/main/python/rootbrowse.py b/main/python/rootbrowse.py index f6b08e9275209bf71a5e901178b8d56a803a1ab3..1dff684dc9b91b3bd75f2c38aa48a1a2b21fee48 100755 --- a/main/python/rootbrowse.py +++ b/main/python/rootbrowse.py @@ -10,8 +10,9 @@ import cmdLineUtils import sys + # Help strings -COMMAND_HELP = "Open a ROOT file in a TBrowser" +description = "Open a ROOT file in a TBrowser" EPILOG = """Examples: - rootbrowse @@ -21,14 +22,21 @@ EPILOG = """Examples: Open the ROOT file 'file.root' in a TBrowser """ +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserSingleFile(description, EPILOG) + parser.prog = 'rootbrowse' + return parser + + def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserSingleFile(COMMAND_HELP, EPILOG) - - # Put arguments in shape - args = cmdLineUtils.getArgs(parser) - - # Process rootBrowse - return cmdLineUtils.rootBrowse(args.FILE) - -sys.exit(execute()) + parser = get_argparse() + + # Put arguments in shape + args = cmdLineUtils.getArgs(parser) + + # Process rootBrowse + return cmdLineUtils.rootBrowse(args.FILE) + +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootcp.py b/main/python/rootcp.py index a8841a75520f0c17def528b91a73e3cb33fab569..02a0e9449c142bf5c170d1139124e57abc060532 100755 --- a/main/python/rootcp.py +++ b/main/python/rootcp.py @@ -10,8 +10,9 @@ import cmdLineUtils import sys + # Help strings -COMMAND_HELP = "Copy objects from ROOT files into an other" +description = "Copy objects from ROOT files into an other" EPILOG = """ Note: If an object has been written to a file multiple times, rootcp will copy only the latest version of that object. @@ -33,20 +34,25 @@ Examples: Change compression factor of 'dest.root' if not existing and copy the histogram named 'hist' from 'source.root' into it. """ +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserSourceDest(description, EPILOG) + parser.prog = 'rootcp' + parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) + parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") + parser.add_argument("-r","--recursive", help=cmdLineUtils.RECURSIVE_HELP, action="store_true") + parser.add_argument("--replace", help=cmdLineUtils.REPLACE_HELP, action="store_true") + return parser + + def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserSourceDest(COMMAND_HELP, EPILOG) - parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) - parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") - parser.add_argument("-r","--recursive", help=cmdLineUtils.RECURSIVE_HELP, action="store_true") - parser.add_argument("--replace", help=cmdLineUtils.REPLACE_HELP, action="store_true") - - # Put arguments in shape - sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) - - # Process rootCp - return cmdLineUtils.rootCp(sourceList, destFileName, destPathSplit, \ - compress=optDict["compress"], recreate=optDict["recreate"], \ - recursive=optDict["recursive"], replace=optDict["replace"]) - -sys.exit(execute()) + parser = get_argparse() + # Put arguments in shape + sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) + + # Process rootCp + return cmdLineUtils.rootCp(sourceList, destFileName, destPathSplit, \ + compress=optDict["compress"], recreate=optDict["recreate"], \ + recursive=optDict["recursive"], replace=optDict["replace"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootdrawtree.py b/main/python/rootdrawtree.py index 053a9abf440751046184b0d059935a88270fe84c..b5e5274de4056ed6c770821c77342838c7f6c5ba 100755 --- a/main/python/rootdrawtree.py +++ b/main/python/rootdrawtree.py @@ -8,12 +8,13 @@ import sys import argparse import ROOT -import textwrap from sys import stderr +import textwrap -parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent('''\ +def get_argparse(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, prog='rootdrawtree', + description=textwrap.dedent('''\ Python script that loops over a chain to create histograms. There are two ways to do it: one is parsing the name of the configuration file as argument, that must have a proper syntax as shown in the class documentation of TSimpleAnalysis. @@ -30,28 +31,33 @@ user@users-desktop:~$ rootdrawtree --output output.root --input hsimple.root --t user@users-desktop:~$ rootdrawtree --output output.root --input hsimple.root hsimple2.root --histo 'hpx=px' 'hpxpy=px:py if px>2' ''')) - -parser.add_argument('configFile', nargs='?', default='', help = "Configuration file") -parser.add_argument('-o', '--output', default='', action='store', dest='output', help='Name of the output file in which will be stored the histograms') -parser.add_argument('-i', '--input', default=[], nargs='*', dest='inputFiles', help='.root input files') -parser.add_argument('-t', '--tree', default='', action='store', dest='tree', help='Name of the tree') -parser.add_argument('-hs', '--histo', default=[], nargs='*', dest='histoExpr', help='Expressions to build the histograms in the form "NAME = EXPRESSION if CUT"') -args = parser.parse_args() -sys.argv = [] - -if (args.configFile != '' and (args.output != '' or args.inputFiles != [] or args.histoExpr != [] or args.tree != '')): - stderr.write("Error: both configuration file and options are provided \n") - exit(1) -if (args.configFile != ''): - a = ROOT.TSimpleAnalysis(args.configFile) - if a.Configure(): + + parser.add_argument('configFile', nargs='?', default='', help = "Configuration file") + parser.add_argument('-o', '--output', default='', action='store', dest='output', help='Name of the output file in which will be stored the histograms') + parser.add_argument('-i', '--input', default=[], nargs='*', dest='inputFiles', help='.root input files') + parser.add_argument('-t', '--tree', default='', action='store', dest='tree', help='Name of the tree') + parser.add_argument('-hs', '--histo', default=[], nargs='*', dest='histoExpr', help='Expressions to build the histograms in the form "NAME = EXPRESSION if CUT"') + return parser + +if __name__ == "__main__": + parser = get_argparse() + + args = parser.parse_args() + sys.argv = [] + + if (args.configFile != '' and (args.output != '' or args.inputFiles != [] or args.histoExpr != [] or args.tree != '')): + stderr.write("Error: both configuration file and options are provided \n") + exit(1) + if (args.configFile != ''): + a = ROOT.TSimpleAnalysis(args.configFile) + if a.Configure(): + a.Run() + else: + inputfile = ROOT.vector("string")(len(args.inputFiles)) + for i,s in enumerate(args.inputFiles): + inputfile[i] = s + expr = ROOT.vector("string")(len(args.histoExpr)) + for k,l in enumerate(args.histoExpr): + expr[k]=l + a = ROOT.TSimpleAnalysis(args.output, inputfile, expr, args.tree) a.Run() -else: - inputfile = ROOT.vector("string")(len(args.inputFiles)) - for i,s in enumerate(args.inputFiles): - inputfile[i] = s - expr = ROOT.vector("string")(len(args.histoExpr)) - for k,l in enumerate(args.histoExpr): - expr[k]=l - a = ROOT.TSimpleAnalysis(args.output, inputfile, expr, args.tree) - a.Run() diff --git a/main/python/rooteventselector.py b/main/python/rooteventselector.py index 042de7f35b8e41e68faef3d7d11a410e9b5654f6..85037d3f11cb68fc54b0928bbe55f33b18a170d1 100755 --- a/main/python/rooteventselector.py +++ b/main/python/rooteventselector.py @@ -15,8 +15,9 @@ import cmdLineUtils import sys + # Help strings -COMMAND_HELP = "Copy subsets of trees from source ROOT files" +description = "Copy subsets of trees from source ROOT files" FIRST_EVENT_HELP = "specify the first event to copy" LAST_EVENT_HELP = "specify the last event to copy" @@ -47,26 +48,30 @@ EPILOG="""Examples: Copy the tree 'tree' from 'source.root' to 'dest.root' and only write branches matching "muon_*" """ +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserSourceDest(description, EPILOG) + parser.prog = 'rooteventselector' + parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) + parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") + parser.add_argument("-f","--first", type=int, default=0, help=FIRST_EVENT_HELP) + parser.add_argument("-l","--last", type=int, default=-1, help=LAST_EVENT_HELP) + parser.add_argument("-s","--selection", default="") + parser.add_argument("-i","--branchinclude", default="") + parser.add_argument("-e","--branchexclude", default="") + return parser + def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserSourceDest(COMMAND_HELP, EPILOG) - parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) - parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") - parser.add_argument("-f","--first", type=int, default=0, help=FIRST_EVENT_HELP) - parser.add_argument("-l","--last", type=int, default=-1, help=LAST_EVENT_HELP) - parser.add_argument("-s","--selection", default="") - parser.add_argument("-i","--branchinclude", default="") - parser.add_argument("-e","--branchexclude", default="") - - # Put arguments in shape - sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) - - # Process rootEventselector - return cmdLineUtils.rootEventselector(sourceList, destFileName, destPathSplit, \ - compress=optDict["compress"], recreate=optDict["recreate"], \ - first=optDict["first"], last=optDict["last"], \ - selectionString=optDict["selection"], \ - branchinclude=optDict["branchinclude"],\ - branchexclude=optDict["branchexclude"]) - -sys.exit(execute()) + parser = get_argparse() + # Put arguments in shape + sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) + + # Process rootEventselector + return cmdLineUtils.rootEventselector(sourceList, destFileName, destPathSplit, \ + compress=optDict["compress"], recreate=optDict["recreate"], \ + first=optDict["first"], last=optDict["last"], \ + selectionString=optDict["selection"], \ + branchinclude=optDict["branchinclude"],\ + branchexclude=optDict["branchexclude"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootls.py b/main/python/rootls.py index ab27a3b3e9883fed8d9dae65f5bef17825ae6637..5c945f56b1fb0fccee7d8ab61e6d9d7f077f3930 100755 --- a/main/python/rootls.py +++ b/main/python/rootls.py @@ -11,11 +11,11 @@ import cmdLineUtils import sys # Help strings -COMMAND_HELP = """Display ROOT files contents in the terminal.""" +description = "Display ROOT files contents in the terminal." ONE_HELP = "Print content in one column" -LONG_PRINT_HELP = "use a long listing format." -TREE_PRINT_HELP = "print tree recursively and use a long listing format." +LONG_PRINT_HELP = "Use a long listing format." +TREE_PRINT_HELP = "Print tree recursively and use a long listing format." EPILOG = """Examples: - rootls example.root @@ -43,18 +43,23 @@ EPILOG = """Examples: Display contents of the ROOT file 'example.root', use a long listing format and print trees recursively. """ -def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserFile(COMMAND_HELP, EPILOG) - parser.add_argument("-1", "--oneColumn", help=ONE_HELP, action="store_true") - parser.add_argument("-l", "--longListing", help=LONG_PRINT_HELP, action="store_true") - parser.add_argument("-t", "--treeListing", help=TREE_PRINT_HELP, action="store_true") - - # Put arguments in shape - sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) +def get_argparse(): + parser = cmdLineUtils.getParserFile(description, EPILOG) + parser.prog = 'rootls' + + parser.add_argument("-1", "--oneColumn", help=ONE_HELP, action= "store_true") + parser.add_argument("-l", "--longListing", help=LONG_PRINT_HELP, action= "store_true") + parser.add_argument("-t", "--treeListing", help=TREE_PRINT_HELP, action= "store_true") + return parser - # Process rootLs - return cmdLineUtils.rootLs(sourceList, oneColumn=optDict["oneColumn"], \ - longListing=optDict["longListing"], treeListing=optDict["treeListing"]) -sys.exit(execute()) +def execute(): + parser = get_argparse() + # Put arguments in shape + sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) + + # Process rootLs + return cmdLineUtils.rootLs(sourceList, oneColumn=optDict["oneColumn"], \ + longListing=optDict["longListing"], treeListing=optDict["treeListing"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootmkdir.py b/main/python/rootmkdir.py index 8122c53b7d80798ad7277ff37853b91f6d0b7190..4675c2029f83bf48ffdad30b897365be0cdbabfb 100755 --- a/main/python/rootmkdir.py +++ b/main/python/rootmkdir.py @@ -11,7 +11,7 @@ import cmdLineUtils import sys # Help strings -COMMAND_HELP = "Add directories in ROOT files" +description = "Add directories in ROOT files" PARENT_HELP = "make parent directories as needed, no error if existing." @@ -29,15 +29,20 @@ EPILOG="""Examples: Create an empty ROOT file named 'example.root' """ -def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserFile(COMMAND_HELP, EPILOG) - parser.add_argument("-p", "--parents", help=PARENT_HELP, action="store_true") +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserFile(description, EPILOG) + parser.prog = 'rootmkdir' + parser.add_argument("-p", "--parents", help=PARENT_HELP, action="store_true") + return parser - # Put arguments in shape - sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser, wildcards = False) +def execute(): + parser = get_argparse() - # Process rootMkdir - return cmdLineUtils.rootMkdir(sourceList, parents=optDict["parents"]) + # Put arguments in shape + sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser, wildcards = False) -sys.exit(execute()) + # Process rootMkdir + return cmdLineUtils.rootMkdir(sourceList, parents=optDict["parents"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootmv.py b/main/python/rootmv.py index 77cd9f9e4323d8d70a9a0dff821a0aa9406f2329..42bfd410e33f6b901cea8684155a22d189d2445d 100755 --- a/main/python/rootmv.py +++ b/main/python/rootmv.py @@ -11,7 +11,7 @@ import cmdLineUtils import sys # Help strings -COMMAND_HELP = "Move objects from ROOT files to another" +description = "Move objects from ROOT files to another" EPILOG = """Examples: - rootmv source.root:hist* dest.root @@ -27,19 +27,24 @@ EPILOG = """Examples: Change the compression level of the destination file 'dest.root' and move the histogram named 'hist' from 'source.root' into it. For more information about compression settings of ROOT file, please look at the reference guide available on the ROOT site. """ -def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserSourceDest(COMMAND_HELP, EPILOG) - parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) - parser.add_argument("-i","--interactive", help=cmdLineUtils.INTERACTIVE_HELP, action="store_true") - parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") - - # Put arguments in shape - sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserSourceDest(description, EPILOG) + parser.prog = 'rootmv' + parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) + parser.add_argument("-i","--interactive", help=cmdLineUtils.INTERACTIVE_HELP, action="store_true") + parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") + return parser - # Process rootMv - return cmdLineUtils.rootMv(sourceList, destFileName, destPathSplit, \ - compress=optDict["compress"], interactive=optDict["interactive"], \ - recreate=optDict["recreate"]) - -sys.exit(execute()) +def execute(): + parser = get_argparse() + + # Put arguments in shape + sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) + + # Process rootMv + return cmdLineUtils.rootMv(sourceList, destFileName, destPathSplit, \ + compress=optDict["compress"], interactive=optDict["interactive"], \ + recreate=optDict["recreate"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootprint.py b/main/python/rootprint.py index 111a786dc81a99cef9d3eb78885f72ca54473bfd..d93344ec059509a48b1ae419c822b40e6cce4f76 100755 --- a/main/python/rootprint.py +++ b/main/python/rootprint.py @@ -11,7 +11,7 @@ import cmdLineUtils import sys # Help strings -COMMAND_HELP = "Print ROOT files contents on ps,pdf or pictures files" +description = "Print ROOT files contents on ps,pdf or pictures files" DIRECTORY_HELP = "put output files in a subdirectory named DIRECTORY." DIVIDE_HELP = "divide the canvas ont the format 'x','y' (ex: 2,2)" @@ -36,26 +36,31 @@ EPILOG = """Examples: Create a pdf file named 'histograms.pdf' which contain all histograms whose name starts with 'hist'. It works also with postscript. """ +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserFile(description, EPILOG) + parser.prog = 'rootprint' + parser.add_argument("-d", "--directory", help=DIRECTORY_HELP) + parser.add_argument("--divide", help=DIVIDE_HELP) + parser.add_argument("-D", "--draw", default="", help=DRAW_HELP) + parser.add_argument("-f", "--format", help=FORMAT_HELP) + parser.add_argument("-o", "--output", help=OUTPUT_HELP) + parser.add_argument("-s", "--size", help=SIZE_HELP) + parser.add_argument("-S", "--style", help=STYLE_HELP) + parser.add_argument("-v", "--verbose", action="store_true", help=VERBOSE_HELP) + return parser + def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserFile(COMMAND_HELP, EPILOG) - parser.add_argument("-d", "--directory", help=DIRECTORY_HELP) - parser.add_argument("--divide", help=DIVIDE_HELP) - parser.add_argument("-D", "--draw", default="", help=DRAW_HELP) - parser.add_argument("-f", "--format", help=FORMAT_HELP) - parser.add_argument("-o", "--output", help=OUTPUT_HELP) - parser.add_argument("-s", "--size", help=SIZE_HELP) - parser.add_argument("-S", "--style", help=STYLE_HELP) - parser.add_argument("-v", "--verbose", action="store_true", help=VERBOSE_HELP) - - # Put arguments in shape - sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) - - # Process rootPrint - return cmdLineUtils.rootPrint(sourceList, directoryOption = optDict["directory"], \ - divideOption = optDict["divide"], drawOption = optDict["draw"], \ - formatOption = optDict["format"], \ - outputOption = optDict["output"], sizeOption = optDict["size"], \ - styleOption = optDict["style"], verboseOption = optDict["verbose"]) - -sys.exit(execute()) + parser = get_argparse() + + # Put arguments in shape + sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) + + # Process rootPrint + return cmdLineUtils.rootPrint(sourceList, directoryOption = optDict["directory"], \ + divideOption = optDict["divide"], drawOption = optDict["draw"], \ + formatOption = optDict["format"], \ + outputOption = optDict["output"], sizeOption = optDict["size"], \ + styleOption = optDict["style"], verboseOption = optDict["verbose"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootrm.py b/main/python/rootrm.py index 348a4348a2b9ee8388f27417af9de630cacdd1a3..5fb8985226138bfea978361d04e5d3b7d0a75a28 100755 --- a/main/python/rootrm.py +++ b/main/python/rootrm.py @@ -11,7 +11,7 @@ import cmdLineUtils import sys # Help strings -COMMAND_HELP = "Remove objects from ROOT files" +description = "Remove objects from ROOT files" EPILOG = """Examples: - rootrm example.root:hist @@ -27,17 +27,22 @@ EPILOG = """Examples: Display a confirmation request before deleting: 'remove 'hist' from 'example.root' ? (y/n) :' """ -def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserFile(COMMAND_HELP, EPILOG) - parser.add_argument("-i","--interactive", help=cmdLineUtils.INTERACTIVE_HELP, action="store_true") - parser.add_argument("-r","--recursive", help=cmdLineUtils.RECURSIVE_HELP, action="store_true") +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserFile(description, EPILOG) + parser.prog = 'rootrm' + parser.add_argument("-i","--interactive", help=cmdLineUtils.INTERACTIVE_HELP, action="store_true") + parser.add_argument("-r","--recursive", help=cmdLineUtils.RECURSIVE_HELP, action="store_true") + return parser - # Put arguments in shape - sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) +def execute(): + parser = get_argparse() - # Process rootRm - return cmdLineUtils.rootRm(sourceList, interactive=optDict["interactive"], \ - recursive=optDict["recursive"]) + # Put arguments in shape + sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser) -sys.exit(execute()) + # Process rootRm + return cmdLineUtils.rootRm(sourceList, interactive=optDict["interactive"], \ + recursive=optDict["recursive"]) +if __name__ == "__main__": + sys.exit(execute()) diff --git a/main/python/rootslimtree.py b/main/python/rootslimtree.py index 7681b4174ed178af822bb41c1911b5bfafa007e3..7392029779780634bf200c89f1d0e998d061b661 100755 --- a/main/python/rootslimtree.py +++ b/main/python/rootslimtree.py @@ -30,23 +30,28 @@ EPILOG="""Examples: Copy the tree 'tree' from 'source.root' to 'dest.root' and only write branches matching "muon_*" """ +def get_argparse(): + # Collect arguments with the module argparse + parser = cmdLineUtils.getParserSourceDest(COMMAND_HELP, EPILOG) + parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) + parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") + parser.add_argument("-i","--branchinclude", default="") + parser.add_argument("-e","--branchexclude", default="") + + return parser + def execute(): - # Collect arguments with the module argparse - parser = cmdLineUtils.getParserSourceDest(COMMAND_HELP, EPILOG) - parser.add_argument("-c","--compress", type=int, help=cmdLineUtils.COMPRESS_HELP) - parser.add_argument("--recreate", help=cmdLineUtils.RECREATE_HELP, action="store_true") - parser.add_argument("-i","--branchinclude", default="") - parser.add_argument("-e","--branchexclude", default="") - - # Put arguments in shape - sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) - - # Process rootEventselector in simplified slimtree mode - return cmdLineUtils.rootEventselector(sourceList, destFileName, destPathSplit, \ - compress=optDict["compress"], recreate=optDict["recreate"], \ - first=0, last=-1, \ - selectionString="", \ - branchinclude=optDict["branchinclude"],\ - branchexclude=optDict["branchexclude"]) - -sys.exit(execute()) + parser = get_argparse() + + # Put arguments in shape + sourceList, destFileName, destPathSplit, optDict = cmdLineUtils.getSourceDestListOptDict(parser) + + # Process rootEventselector in simplified slimtree mode + return cmdLineUtils.rootEventselector(sourceList, destFileName, destPathSplit, \ + compress=optDict["compress"], recreate=optDict["recreate"], \ + first=0, last=-1, \ + selectionString="", \ + branchinclude=optDict["branchinclude"],\ + branchexclude=optDict["branchexclude"]) +if __name__ == "__main__": + sys.exit(execute())