7 from hist_bookkeep_utils
import get_val, get_comm_def, weed, get_hbuff
9 parser = argparse.ArgumentParser(
11 take two files and find overlapping histogram definitions.
12 Write out overlapping, different (in 1st file and 2nd file),
13 and exclusive (only 1st file, only 2nd file'''
16 parser.add_argument(
'--xml1',
20 help=
'xml 1 file with histogram definitions')
22 parser.add_argument(
'--xml2',
26 help=
'xml 2 file with histogram definitions')
28 args = parser.parse_args()
78 elif (
"textdiff"==test):
86 if (
"error"==testx
or "error"==testy):
88 elif (
"textdiff"==testx
or "textdiff"==testy):
90 elif (
"rangediff"==testx
or "rangediff"==testy):
102 infname1=args.in_xml1.name
103 infname2=args.in_xml2.name
105 outfname_common=infname1.split(
".")[0]+
"_"+infname2.split(
".")[0]+
".xml"
106 outfname_1only=infname1.split(
".")[0]+
"_only.xml"
107 outfname_2only=infname2.split(
".")[0]+
"_only.xml"
108 outfname_1diffrange=infname1.split(
".")[0]+
"_diffrange.xml"
109 outfname_2diffrange=infname2.split(
".")[0]+
"_diffrange.xml"
110 outfname_1difftext=infname1.split(
".")[0]+
"_difftext.xml"
111 outfname_2difftext=infname2.split(
".")[0]+
"_difftext.xml"
114 print(
' reading histogram xml definitions in ', infname1, infname2)
115 print(
' writing histograms only in ', infname1,
'to', outfname_1only)
116 print(
' writing histograms only in ', infname2,
'to', outfname_2only)
117 print(
' writing histograms range diff in ', infname1,
'to', outfname_1diffrange)
118 print(
' writing histograms range diff in ', infname2,
'to', outfname_2diffrange)
119 print(
' writing histograms text diff in ', infname1,
'to', outfname_1difftext)
120 print(
' writing histograms text diff in ', infname2,
'to', outfname_2difftext)
121 print(
' writing histograms common to both to', outfname_common)
124 outf_common=
open(outfname_common,
'w')
125 outf_1only=
open(outfname_1only,
'w')
126 outf_2only=
open(outfname_2only,
'w')
127 outf_1diffrange=
open(outfname_1diffrange,
'w')
128 outf_2diffrange=
open(outfname_2diffrange,
'w')
129 outf_1difftext=
open(outfname_1difftext,
'w')
130 outf_2difftext=
open(outfname_2difftext,
'w')
134 buff_comp_dict={0:outf_common,
135 1:outf_1only,2:outf_2only,
136 3:outf_1diffrange,4:outf_2diffrange,
137 5:outf_1difftext,6:outf_2difftext}
143 for line
in args.in_xml1:
144 if line.strip().startswith(
"<h"):
153 for _val,_buff
in zip(compvals,buffs):
154 for dkey,dval
in buff_comp_dict.iteritems():
167 for line
in args.in_xml2:
169 if line.strip().startswith(
"<h"):
175 buff_comp_dict[2].
write(_bitem)
183 for key,of
in buff_comp_dict.iteritems():