Created
June 15, 2013 21:48
-
-
Save yasyf/5789696 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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