fix: missing version dot
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime
|
||||
import json
|
||||
import hashlib
|
||||
from typing import Callable
|
||||
|
||||
SALT = b"Lt2N5xgjJOqRsT5qVt7wWYw6SqOPZDI7"
|
||||
|
||||
@@ -11,7 +12,7 @@ def salted_hash_userid(player: dict):
|
||||
player["userId"] = hash_uid.hexdigest()[:16]
|
||||
|
||||
|
||||
def remove_useless_fields(player: dict):
|
||||
def clean_player(player: dict):
|
||||
player.pop("isLogin")
|
||||
player.pop("lastLoginDate")
|
||||
player.pop("lastPlayDate")
|
||||
@@ -33,23 +34,35 @@ def record_time(*, _: list[datetime] = []):
|
||||
return diff
|
||||
|
||||
|
||||
def main():
|
||||
def process(
|
||||
clean_fields: Callable[[dict], None],
|
||||
input_file: str,
|
||||
output_file: str,
|
||||
):
|
||||
record_time()
|
||||
with open("players.json", "r", encoding="utf-8") as f:
|
||||
with open(input_file, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
print(f"loaded, cost {record_time():.2f}s")
|
||||
|
||||
record_time()
|
||||
for entry in data:
|
||||
salted_hash_userid(entry)
|
||||
remove_useless_fields(entry)
|
||||
clean_fields(entry)
|
||||
print(f"processed, cost {record_time():.2f}s")
|
||||
|
||||
record_time()
|
||||
with open("players_pub.json", "w", encoding="utf-8") as f:
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False)
|
||||
print(f"written out, cost {record_time():.2f}s")
|
||||
|
||||
|
||||
def main():
|
||||
process(
|
||||
clean_player,
|
||||
"players.json",
|
||||
"players_pub.json",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user