Skip to content

Instantly share code, notes, and snippets.

@abbot
Created June 9, 2009 06:59
Show Gist options
  • Save abbot/126323 to your computer and use it in GitHub Desktop.
Save abbot/126323 to your computer and use it in GitHub Desktop.
import os, re, sys
r = re.compile(r'abc xyz = "(.*)"')
def matches(f):
return ['%s:%s' % (f, m.group(1)) for m in (r.match(l) for l in open(f, "r")) if m]
for fn in (fn for fn in os.listdir(len(sys.argv) > 1 and sys.argv[1] or '.') if os.path.isfile(fn)):
rc = matches(fn)
if rc: print "\n".join(rc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment