Skip to content

Instantly share code, notes, and snippets.

@itsthejb
Created January 26, 2018 12:41
Show Gist options
  • Save itsthejb/65d8d89208daf9a44f137be26305386a to your computer and use it in GitHub Desktop.
Save itsthejb/65d8d89208daf9a44f137be26305386a to your computer and use it in GitHub Desktop.
Convert an .hcmask mask file to a plain mask
#!/usr/bin/env python3
import sys
import textwrap
if len(sys.argv) != 2:
print("Usage: {} <.hcmask>".format(sys.argv[0]))
exit(1)
with open(sys.argv[1], "r") as f:
mask = f.readline()
while mask:
comps = mask.split(",")
filt = { "?{}".format(str(i[0] + 1)) : i[1] for i in enumerate(comps[:-1]) }
out = "".join([filt[chunk] for chunk in textwrap.wrap(comps[-1], 2)])
print(out)
mask = f.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment