diff options
Diffstat (limited to 'ATRI/plugins/plugin_utils/generate.py')
-rw-r--r-- | ATRI/plugins/plugin_utils/generate.py | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/ATRI/plugins/plugin_utils/generate.py b/ATRI/plugins/plugin_utils/generate.py deleted file mode 100644 index 4749bab..0000000 --- a/ATRI/plugins/plugin_utils/generate.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : generateID.py -@Time : 2020/11/08 10:35:09 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import os -import json -import random -from pathlib import Path -from zipfile import PyZipFile -from typing import Tuple, Dict, List - -FILE = Path('.') / 'ATRI' / 'plguins' / 'plugin_utils' / 'main.bin' - - -def infoID() -> Tuple[Dict[str, List[str]], Dict[str, str]]: - with PyZipFile(os.path.abspath(FILE), "r") as zipFile: - with zipFile.open("name.json", "r") as f: - name = json.loads(f.read().decode()) - with zipFile.open("area.json", "r") as f: - area = json.loads(f.read().decode()) - return name, area - - -def numberID(area: int, sex: int, birth: int) -> str: - def checkSum(fullCode: str) -> int or str: - assert len(fullCode) == 17 - checkSum = sum([((1 << (17 - i)) % 11) * int(fullCode[i]) - for i in range(0, 17)]) - checkDigit = (12 - (checkSum % 11)) % 11 - if checkDigit < 10: - return checkDigit - else: - return "X" # type: ignore - - orderCode = str(random.randint(10, 99)) - sexCode = str(random.randrange(sex, 10, step=2)) - fullCode = str(area) + str(birth) + str(orderCode) + str(sexCode) - fullCode += str(checkSum(fullCode)) - return fullCode |