85 lines
2.4 KiB
Python
85 lines
2.4 KiB
Python
# status stuff from project
|
|
|
|
import helpers.utils as utils
|
|
|
|
import os
|
|
from rich import print
|
|
from datetime import datetime
|
|
|
|
def is_key_defined(name, default):
|
|
key = utils.get_config(name)
|
|
|
|
if key == default:
|
|
return [False]
|
|
|
|
return [True, key]
|
|
|
|
def is_file_present(path):
|
|
full_path = utils.get_path(path)
|
|
present = os.path.isfile(full_path)
|
|
return present
|
|
|
|
def get_status():
|
|
file = None
|
|
text_util = lambda file, folder: [is_file_present(f"blk/{(file := file)}.blk"), f"{str(folder).zfill(2)}/{file}.blk"]
|
|
|
|
# TODO: use config for blocks id
|
|
status = {
|
|
"Blocks": {
|
|
"BinOutput": text_util(24230448, 0),
|
|
"ExcelBinOutput": text_util(25539185, 0),
|
|
"AssetIndex": text_util(31049740, 0),
|
|
"LuaScripts": text_util(35323818, 0)
|
|
},
|
|
"Textmaps": {
|
|
"CHS": text_util(26692920, 1),
|
|
"CHT": text_util(27251172, 2),
|
|
"DE": text_util(25181351, 3),
|
|
"EN": text_util(25776943, 4),
|
|
"ES": text_util(20618174, 5),
|
|
"FR": text_util(25555476, 6),
|
|
"ID": text_util(30460104, 7),
|
|
"JP": text_util(32244380, 8),
|
|
"KR": text_util(22299426, 9),
|
|
"PT": text_util(23331191, 10),
|
|
"RU": text_util(21030516, 11),
|
|
"TH": text_util(32056053, 12),
|
|
"VI": text_util(34382464, 13),
|
|
"IT": text_util(27270675, 14),
|
|
"TR": text_util(21419401, 15)
|
|
}
|
|
}
|
|
|
|
gameTarget = is_key_defined("gameTarget", None)
|
|
index = False
|
|
if gameTarget[0]:
|
|
indexCheck = is_file_present(f"configs/indexes/index.{gameTarget[1]}.json")
|
|
metaCheck = is_file_present(f"configs/indexes/index.{gameTarget[1]}.meta.json")
|
|
|
|
index = True
|
|
if any([not indexCheck, not metaCheck]):
|
|
index = False
|
|
|
|
if index:
|
|
meta = utils.get_index_meta(gameTarget[1])
|
|
timeText = datetime.fromtimestamp(meta["time"]).strftime("%m/%d/%Y")
|
|
indexText = f'generated on {timeText} | {round(meta["size"] / 1048576, 2)} Mb | {"{0:.2%}".format(meta["coverage"])} coverage'
|
|
|
|
status["Configs"] = {
|
|
"GameTarget": [gameTarget[0], f"target : v{gameTarget[1]}" if gameTarget[0] else "not defined yet"],
|
|
"Index": [index, indexText if index else "not generated yet"]
|
|
}
|
|
|
|
return status
|
|
|
|
def print_status():
|
|
status = get_status()
|
|
|
|
for cat, values in status.items():
|
|
print(f"[bold underline]{cat}[/bold underline]")
|
|
|
|
for elem, state in values.items():
|
|
symbol = "[green]\u2713[/green]" if state[0] else "[red]\u2718[/red]"
|
|
additional = f"[dim white] ({state[1]})[/dim white]" if state[1] != "" else ""
|
|
|
|
print(f"{symbol} {elem}{additional}")
|