forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootprint.py
More file actions
executable file
·69 lines (56 loc) · 2.78 KB
/
rootprint.py
File metadata and controls
executable file
·69 lines (56 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env @python@
# ROOT command line tools: rootprint
# Author: Julien Ripoche
# Mail: julien.ripoche@u-psud.fr
# Date: 20/08/15
"""Command line to print ROOT files contents on ps,pdf or png,gif..."""
import cmdLineUtils
import sys
# Help strings
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)"
DRAW_HELP = "specify draw option"
FORMAT_HELP = "specify output format (ex: pdf, png)."
OUTPUT_HELP = "merge files in a file named OUTPUT (only for ps and pdf)."
SIZE_HELP = "specify canvas size on the format 'width'x'height' (ex: 600x400)"
STYLE_HELP = "specify a C file name which define a style"
VERBOSE_HELP = "print informations about the running"
RECURSIVE_HELP = "Traverse file recursively entering any TDirectory."
EPILOG = """Examples:
- rootprint example.root:hist
Create a pdf file named 'hist.pdf' which contain the histogram 'hist'.
- rootprint -d histograms example.root:hist
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).
- rootprint -f png example.root:hist
Create a png file named 'hist.png' which contain the histogram 'hist'.
- rootprint -o histograms.pdf example.root:hist*
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)
parser.add_argument("-r", "--recursive", action="store_true", help=RECURSIVE_HELP)
return parser
def 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"], \
recursiveOption = optDict["recursive"])
if __name__ == "__main__":
sys.exit(execute())