Skip to content

Instantly share code, notes, and snippets.

@tmhedberg
Created May 31, 2011 17:41
Show Gist options
  • Save tmhedberg/1000944 to your computer and use it in GitHub Desktop.
Save tmhedberg/1000944 to your computer and use it in GitHub Desktop.
Compile an Intermec Fingerprint source file to its directly executable format
#!/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