3 """Transform find-fix.py output into Excellable csv."""
5 __date__
= "Time-stamp: <2003-10-16 13:26:27 jrepenning>"[13:30]
6 __author__
= "Jack Repenning <jrepenning@collab.net>"
10 my_getopt
= getopt
.gnu_getopt
11 except AttributeError:
12 my_getopt
= getopt
.getopt
23 # Long options and their usage strings; "=" means it takes an argument.
24 # To get a list suitable for getopt, just do
26 # [x[0] for x in long_opts]
28 # Make sure to sacrifice a lamb to Guido for each element of the list.
30 ["doc", """Optional, print pydocs."""],
31 ["help", """Optional, print usage (this text)."""],
32 ["verbose", """Optional, print more progress messages."""],
37 me
= os
.path
.basename(sys
.argv
[0])
39 DATA_FILE
= "http://subversion.tigris.org/iz-data/query-set-1.tsv"
42 """Run find-fix.py with arguments du jour for drawing pretty
43 manager-speak pictures."""
48 opts
, args
= my_getopt(sys
.argv
[1:], "", [x
[0] for x
in long_opts
])
49 except getopt
.GetoptError
, e
:
50 print "Error: ", e
.msg
52 print me
+ " --help for options."
59 elif opt
== "--verbose":
62 pydoc
.doc(pydoc
.importfile(sys
.argv
[0]))
65 # do something fruitful with your life
67 args
= ["query-set-1.tsv", "core-history.csv"]
68 print ("ff2csv %s %s" % args
)
71 print "%s: Wrong number of args." % me
75 if os
.system("curl " + DATA_FILE
+ "> " + args
[0]):
76 os
.system("wget " + DATA_FILE
)
78 outfile
= file(args
[1], "w")
79 outfile
.write("Date,found,fixed,inval,dup,other,remain\n")
81 totalsre
= re
.compile("totals:.*found= +([0-9]+) +"
87 for year
in ("2001", "2002", "2003", "2004"):
88 for month
in ("01", "02", "03", "04", "05", "06", "07", "08",
89 "09", "10", "11", "12"):
90 for dayrange
in (("01", "08"),
95 print "searching %s-%s-%s to %s" % (year
,
99 ffpy
= os
.popen("python ./find-fix.py --m=beta "
100 "%s %s-%s-%s %s-%s-%s"
102 year
, month
, dayrange
[0],
103 year
, month
, dayrange
[1]))
107 line
= ffpy
.readline()
109 print "initial line is: ", line
110 matches
= totalsre
.search(line
)
112 print "initial match is: ", matches
113 while line
and not matches
:
114 line
= ffpy
.readline()
116 print "%s: read line '%s'" % (me
, line
)
117 matches
= totalsre
.search(line
)
119 print "subsequent line is: ", line
124 print "line is ", line
126 if matches
.group(1) != "0" \
127 or matches
.group(2) != "0" \
128 or matches
.group(3) != "0" \
129 or matches
.group(4) != "0" \
130 or matches
.group(5) != "0":
132 outfile
.write("%s-%s-%s,%s,%s,%s,%s,%s,%s\n"
133 % (year
, month
, dayrange
[1],
141 elif matches
.group(6) != "0":
142 # quit at first nothing-done week
143 # allows slop in loop controls
149 "Print one-line usage summary."
150 print "%s - %s" % (me
, pydoc
.synopsis(sys
.argv
[0]))
153 "Print multi-line usage tome."
155 print '''%s [opts] [queryfile [outfile]]
156 Option keywords may be abbreviated to any unique prefix.
157 Option order is not important.
158 Most options require "=xxx" arguments:''' % me
162 print " --" + x
[0][:-1],
166 print (' ' * (padding_limit
- len(x
[0]))), x
[1]
168 if __name__
== "__main__":