SVN: toys/cvsstats/email2sql.py
pawelz
pawelz at pld-linux.org
Sun Feb 28 15:25:54 CET 2010
Author: pawelz
Date: Sun Feb 28 15:25:54 2010
New Revision: 11219
Modified:
toys/cvsstats/email2sql.py
Log:
- implement commandline options, let -d means "debug".
Modified: toys/cvsstats/email2sql.py
==============================================================================
--- toys/cvsstats/email2sql.py (original)
+++ toys/cvsstats/email2sql.py Sun Feb 28 15:25:54 2010
@@ -7,6 +7,17 @@
import re
import time
+# debug:
+# 0 - no debug
+# 1 - print filenames
+# 2 - print some extra crap
+# 3 - print decoded message bodys (warning: it won't produce valid SQL
+# script)
+#
+# set it using -d flag. For example to set debug = 2 use:
+# ./email2sql -d -d file
+debug = 0
+
rmsg = re.compile(
"^Author: (?P<author>\S+)\s+Date: (?P<date>.*)\n"
"Module: (?P<module>\S+)\s+Tag: (?P<tag>.*)\n"
@@ -46,6 +57,11 @@
if (not p):
p = str(msg)
+ if (debug >= 3):
+ print "{{{"
+ print p
+ print "}}}"
+
m = rmsg.search(p)
if m:
self.author = m.group("author")
@@ -124,11 +140,21 @@
if __name__ == '__main__':
for f in sys.argv:
+ if f[0] == "-":
+ if f == "-d":
+ debug += 1
+ else:
+ print >> sys.stderr, "Warning, unrecognized option %s", f
+
+ for f in sys.argv:
if f == sys.argv[0]:
continue
+ if f[0] == "-":
+ continue
try:
+ if debug >= 1:
+ print "-- %s" % f
c = commit(f)
- print "-- %s" % f
c.files_sql()
c.commit_sql()
except:
More information about the pld-cvs-commit
mailing list