Last active
December 5, 2019 17:40
-
-
Save erikaderstedt/6b238875ef9824a2a6a87eb42e276ded to your computer and use it in GitHub Desktop.
This file contains 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
import sys | |
import re | |
x = re.compile('(\S+):') | |
s = open(sys.argv[1],'r').readlines() | |
s = [x.strip() for x in s] | |
s = [x for x in s if x[:2] != '//' and x != ''] | |
cmds = [] | |
tags = {} | |
for r in s: | |
m = x.match(r) | |
if m is not None: | |
tags[m.groups()[0]] = len(cmds) | |
else: | |
cmds.extend([x for x in r.split(',') if x != '']) | |
cmds = [tags.get(x) if x in tags else int(x) for x in cmds] | |
print(','.join([str(x) for x in cmds])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment