1
0
mirror of synced 2024-11-24 14:30:11 +01:00
bemaniutils/bemani/utils/cardconvert.py
2019-12-08 21:43:49 +00:00

29 lines
774 B
Python

import argparse
from bemani.common import CardCipher, CardCipherException
def main() -> None:
parser = argparse.ArgumentParser(description="A utility to convert between card IDs and back-of-card characters.")
parser.add_argument(
"number",
help="card ID or back-of-card characters to convert.",
type=str,
)
args = parser.parse_args()
try:
print(CardCipher.decode(args.number))
except CardCipherException:
try:
back = CardCipher.encode(args.number)
print(" ".join([
back[i:(i + 4)] for i in range(0, len(back), 4)
]))
except CardCipherException:
print('Bad card ID or back-of-card characters!')
if __name__ == '__main__':
main()