Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
rootprint.py
Go to the documentation of this file.
1#!/usr/bin/env @python@
2
3# ROOT command line tools: rootprint
4# Author: Julien Ripoche
5# Mail: julien.ripoche@u-psud.fr
6# Date: 20/08/15
7
8"""Command line to print ROOT files contents on ps,pdf or png,gif..."""
9
10import cmdLineUtils
11import sys
12
13# Help strings
14description = "Print ROOT files contents on ps,pdf or pictures files"
15
16DIRECTORY_HELP = "put output files in a subdirectory named DIRECTORY."
17DIVIDE_HELP = "divide the canvas ont the format 'x','y' (ex: 2,2)"
18DRAW_HELP = "specify draw option"
19FORMAT_HELP = "specify output format (ex: pdf, png)."
20OUTPUT_HELP = "merge files in a file named OUTPUT (only for ps and pdf)."
21SIZE_HELP = "specify canvas size on the format 'width'x'height' (ex: 600x400)"
22STYLE_HELP = "specify a C file name which define a style"
23VERBOSE_HELP = "print informations about the running"
24RECURSIVE_HELP = "Traverse file recursively entering any TDirectory."
25
26EPILOG = """Examples:
27- rootprint example.root:hist
28 Create a pdf file named 'hist.pdf' which contain the histogram 'hist'.
29
30- rootprint -d histograms example.root:hist
31 Create a pdf file named 'hist.pdf' which contain the histogram 'hist' and put it in the directory 'histograms' (create it if not already exists).
32
33- rootprint -f png example.root:hist
34 Create a png file named 'hist.png' which contain the histogram 'hist'.
35
36- rootprint -o histograms.pdf example.root:hist*
37 Create a pdf file named 'histograms.pdf' which contain all histograms whose name starts with 'hist'. It works also with postscript.
38"""
39
41 # Collect arguments with the module argparse
42 parser = cmdLineUtils.getParserFile(description, EPILOG)
43 parser.prog = 'rootprint'
44 parser.add_argument("-d", "--directory", help=DIRECTORY_HELP)
45 parser.add_argument("--divide", help=DIVIDE_HELP)
46 parser.add_argument("-D", "--draw", default="", help=DRAW_HELP)
47 parser.add_argument("-f", "--format", help=FORMAT_HELP)
48 parser.add_argument("-o", "--output", help=OUTPUT_HELP)
49 parser.add_argument("-s", "--size", help=SIZE_HELP)
50 parser.add_argument("-S", "--style", help=STYLE_HELP)
51 parser.add_argument("-v", "--verbose", action="store_true", help=VERBOSE_HELP)
52 parser.add_argument("-r", "--recursive", action="store_true", help=RECURSIVE_HELP)
53 return parser
54
55def execute():
56 parser = get_argparse()
57
58 # Put arguments in shape
59 sourceList, optDict = cmdLineUtils.getSourceListOptDict(parser)
60
61 # Process rootPrint
62 return cmdLineUtils.rootPrint(sourceList, directoryOption = optDict["directory"], \
63 divideOption = optDict["divide"], drawOption = optDict["draw"], \
64 formatOption = optDict["format"], \
65 outputOption = optDict["output"], sizeOption = optDict["size"], \
66 styleOption = optDict["style"], verboseOption = optDict["verbose"], \
67 recursiveOption = optDict["recursive"])
68if __name__ == "__main__":
69 sys.exit(execute())
rootPrint(sourceList, directoryOption=None, divideOption=None, drawOption="", formatOption=None, outputOption=None, sizeOption=None, styleOption=None, verboseOption=False, recursiveOption=False)
getSourceListOptDict(parser, wildcards=True)
Get the list of tuples and the dictionary with options.
getParserFile(theHelp, theEpilog="")
Get a commandline parser with the defaults of the commandline utils and a list of source files.
get_argparse()
Definition rootprint.py:40