Created
May 31, 2011 17:41
-
-
Save tmhedberg/1000944 to your computer and use it in GitHub Desktop.
Compile an Intermec Fingerprint source file to its directly executable format
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/python | |
import re | |
import sys | |
argc = len(sys.argv) | |
ifd = sys.stdin if argc <= 1 else open(sys.argv[1]) | |
ofd = sys.stdout if argc <= 2 else open(sys.argv[2], mode="w") | |
lnum = 10 | |
for l in ifd: | |
if not (re.match(r"('.*)?$", l) or | |
re.match(r"IMMEDIATE |NEW\s*$|RUN\s*$", l, flags=re.I)): | |
l = re.sub(r"\s*:'.*$", "", l) | |
print(lnum, l, end="", file=ofd) | |
lnum += 10 | |
if ifd != sys.stdin: | |
ifd.close() | |
if ofd != sys.stdout: | |
ofd.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment