import sys import py def main(author, month): data = py.process.cmdexec('svn log -v') sep = "------------------------------------------------------------------------" sections = data.split(sep) monthly_added = 0 monthly_removed = 0 for section in sections: section = section.strip() section_lines = section.splitlines() if not section_lines: continue try: rev, auth, date, junk = section_lines[0].split("|") except ValueError: continue if author not in auth: continue if month not in date: continue print section added, removed = get_changed_lines(int(rev[1:])) monthly_added += added monthly_removed += removed print "Added:", added print "Removed: ", removed print "Net: ", added-removed print sep print "Monthly Added:", monthly_added print "Monthly Removed:", monthly_removed print "Monthly Net:", monthly_added-monthly_removed def get_changed_lines(rev): out = py.process.cmdexec('svn diff -r %s:%s' % (rev-1, rev)) out_lines = out.strip().splitlines() added = 0 removed = 0 for line in out_lines: if line.startswith('+ '): added += 1 elif line.startswith('- '): removed += 1 return added, removed if __name__ == '__main__': main(sys.argv[1], sys.argv[2])