2019-12-08 22:43:49 +01:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
from bemani.common import CardCipher, CardCipherException
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="A utility to convert between card IDs and back-of-card characters."
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
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)
|
2022-10-15 20:56:30 +02:00
|
|
|
print(" ".join([back[i : (i + 4)] for i in range(0, len(back), 4)]))
|
2019-12-08 22:43:49 +01:00
|
|
|
except CardCipherException:
|
2022-10-15 20:56:30 +02:00
|
|
|
print("Bad card ID or back-of-card characters!")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
if __name__ == "__main__":
|
2019-12-08 22:43:49 +01:00
|
|
|
main()
|