Author: pawelz Date: Mon Mar 1 12:29:22 2010 New Revision: 11222 Modified: toys/cvsstats/email2sql.py Log: - added a lot of dbg(...), and succesfully killed a bug. - Now I know understand for ... else ... works in python.
Modified: toys/cvsstats/email2sql.py ============================================================================== --- toys/cvsstats/email2sql.py (original) +++ toys/cvsstats/email2sql.py Mon Mar 1 12:29:22 2010 @@ -12,6 +12,7 @@ # 1 - print filenames # 2 - print some extra crap # 3 - print decoded message bodys +# 4 - print decoded parts of message (like log, files affected etc) # # set it using -d flag. For example to set debug = 2 use: # ./email2sql -d -d file @@ -66,10 +67,14 @@ if (not p): p = str(msg) - dbg(3, "{{{\n" + p + "\n}}}") + dbg(3, "{{{ MESSAGE BODY\n" + p + "\n}}}") m = rmsg.search(p) if m: + dbg(4, "{{{ LOG\n" + m.group("log") + "\n}}}") + dbg(4, "{{{ FILES\n" + m.group("files") + "\n}}}") + dbg(4, "{{{ DIFF\n" + m.group("diff") + "\n}}}") + self.author = m.group("author") d = time.strptime(m.group("date")[0:-4]) self.date = "%i-%i-%i %i:%i:%i" % (d.tm_year, d.tm_mon, d.tm_mday, @@ -84,6 +89,8 @@ def parse_diff(self, diff): current_file=None + dbg(4, "{{{ PARSING DIFF\n" + diff + "\n}}}") + for line in diff.splitlines(): if line == "---- CVS-web:": @@ -92,6 +99,7 @@ # is it a beginig of the new file? m = rindex.match(line) if (m): + dbg(3, "Matched file: %s" % m.group("file")) if (current_file): self.fdata[current_file] = (hunks, added, removed) self.hunks += hunks @@ -109,6 +117,7 @@ try: if line[0] == "@": + dbg(3, "Begining of hunk: %s" % line) hunks += 1 except IndexError: continue @@ -116,16 +125,18 @@ # don't read any line before the begining of the first hunk! if hunks > 0: if line[0] == "+": + dbg(3, "Added line: %s" % line) added += 1 if line[0] == "-": + dbg(3, "Removed line: %s" % line) removed += 1 - else: - if (current_file): - self.fdata[current_file] = (hunks, added, removed) - self.hunks += hunks - self.added += added - self.removed += removed + + if (current_file): + self.fdata[current_file] = (hunks, added, removed) + self.hunks += hunks + self.added += added + self.removed += removed def files_report(self): for f in self.fdata: _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit