Created
January 26, 2018 12:41
-
-
Save itsthejb/65d8d89208daf9a44f137be26305386a to your computer and use it in GitHub Desktop.
Convert an .hcmask mask file to a plain mask
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 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