Skip to content

Instantly share code, notes, and snippets.

@josip
Created August 8, 2009 13:34
Show Gist options
  • Save josip/164414 to your computer and use it in GitHub Desktop.
Save josip/164414 to your computer and use it in GitHub Desktop.
import sys
import re
changes_re = re.compile('^(\-{3}|\+{3}) (.+)\s+\d{4}\-\d{2}-\d{2}.*$')
lines = open(sys.argv[0], 'r').readlines()
diffs = {}
last_path = ''
for line in lines:
path = changes_re.findall(line)
if len(path):
last_path = path[0][1]
diffs[last_path] = {'mode': path[0][0][0], 'diff': ''}
if len(last_path):
diffs[last_path]['diff'] += line
print diffs[last_path]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment