Skip to content

Instantly share code, notes, and snippets.

@yasyf
Created June 15, 2013 21:48
Show Gist options
  • Select an option

  • Save yasyf/5789696 to your computer and use it in GitHub Desktop.

Select an option

Save yasyf/5789696 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys,re
sqbraces='(\\[.*?\\])' # Square Braces
regex = re.compile(sqbraces,re.IGNORECASE|re.DOTALL)
input = sys.argv[1]
printname = True
for line in open(input).readlines():
if line.isspace():
continue
else:
line = line.strip()
found = regex.search(line)
if found:
toreplace = found.group(0)
replaced = line.replace(toreplace,"").strip()
name = replaced[:replaced.find(":")]
if printname:
print "\r\n[%s]" % name,
else:
print "\r\n-",
print replaced[replaced.find(":")+1:].strip(),
else:
print line,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment