66 parser = optparse.OptionParser(description=__doc__,
67 usage=
'%prog [Options] file [path]')
69 parser.add_option(
'-t',
'--total', action=
'store_true',
70 help=
'Print total number of histograms and bins')
72 parser.add_option(
'-b',
'--bins', action=
'store_true',
73 help=
'Sort by number of bins')
75 parser.add_option(
'-n',
'--byName', action=
'store_true',
76 help=
'Show histograms [default]')
78 parser.add_option(
'-a',
'--byAlg', action=
'store_true',
79 help=
'Show total histograms per algorithm')
81 parser.add_option(
'-f',
'--filled', action=
'store_true',
82 help=
'Show number of filled bins instead of total bins')
84 parser.add_option(
'-l',
'--labeled', action=
'store_true',
85 help=
'Only show histograms with text labels')
87 parser.add_option(
'-m',
'--misslabel', action=
'store_true',
88 help=
'Only show labeled histograms with at least one unlabeled bin')
90 parser.add_option(
'-e',
'--empty', action=
'store_true',
91 help=
'Only show histograms with zero entries')
94 (opts, args) = parser.parse_args()
104 hists =
list(args[0],path)
105 if opts.bins: sortKey =
lambda x : x[1][1]
108 if not opts.byAlg: opts.byName =
True
110 if opts.byName
is True:
111 for h,v
in sorted(hists.items(), key=sortKey):
112 print(
'%-80s %10s %10s' % (h,v[0],v[1]))
114 if opts.byAlg
is True:
116 for h,v
in sorted(algs.items(), key=sortKey):
117 print(
'%-80s %10s %10s' % (h,v[0],v[1]))
121 print(
"Total histograms: %15s" % len(hists))
122 print(
"Total %sbins: %15s" % (
"filled " if opts.filled
else "",
sum([h[1]
for h
in hists.values()])))