3 parser = argparse.ArgumentParser(description=
"%prog [options]", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
4 parser.add_argument(
"-doStatus", dest=
'doStatus', action=
'store_true', default=
False, help=
"compare Status tag")
5 parser.add_argument(
"-doStatusHT", dest=
'doHT', action=
'store_true', default=
False, help=
"compare StatusHT tag")
6 parser.add_argument(
"-doStatusPermanent", dest=
'doPermanent', action=
'store_true', default=
False, help=
"compare StatusPermanent tag")
7 parser.add_argument(
"-inFile", dest=
'IFile', default=
None, help=
"hand-made file (input to txt2db_template.py) to compare to output")
8 parser.add_argument(
"-outFile", dest=
'OFile', default=
None, help=
"file dumped from db2txt_template.py to compare to input")
9 args = parser.parse_args()
14 ITxt=
open(IFileIn).readlines()
15 OTxt=
open(OFileIn).readlines()
25 if not (args.doStatus
or args.doPermanent
or args.doHT):
26 print "please specify doStatus, doPermanent, and/or doHT"
31 if "permanent Status" in line:
33 if "HT Status" in line:
35 if "Status" in line
and not (
"permanent" in line
or "HT" in line):
37 if (args.doPermanent
and not isPermanent)
or (args.doHT
and not isHT)
or (args.doStatus
and not isStatus):
38 print "check your inputs, they don't have the requested Status type"
44 line=line.replace(
" ",
" ")
45 line=line[0].
replace(
" ",
"")+line[1:]
46 line=line[:-1]+line[-1].
replace(
" ",
"")
47 tokens=line.split(
" ")
49 if not "Status:" in tokens:
50 print "length not satisfied: ",tokens
52 Inewtokens.append(line.split(
"\n")[0])
58 line=line.replace(
" ",
" ")
59 line=line[0].
replace(
" ",
"")+line[1:]
60 if isPermanent
or isStatus:
61 line=line.replace(
"257",
"1")
62 line=line[:-1]+line[-1].
replace(
" ",
"")
63 if (isHT
or isStatus)
and "2" in line.split(
" ")[-1].
split(
"\n")[0]:
66 tokens=line.split(
" ")
68 if (
not seenEnd)
and "permanent" in tokens:
70 elif seenStart
and "Status:" in tokens:
73 if (
not seenEnd)
and "HT" in tokens:
75 elif seenStart
and "Status:" in tokens:
78 if (
not seenEnd)
and "Status:" in tokens
and not (
"HT" in tokens
or "permanent" in tokens):
80 elif seenStart
and (
"HT" in tokens
or "permanent" in tokens):
82 if seenStart
and not seenEnd:
84 if not "Status:" in tokens:
85 print "length not satisfied: ",tokens
87 Onewtokens.append(tokens[0]+
" " \
92 +tokens[5].
split(
"\n")[0] \
95 print set(Inewtokens) ^
set(Onewtokens)
97 if __name__==
'__main__':