优化提示信息

This commit is contained in:
xzb23 committed 2026-11-22 18:46:55 +08:00
1 parent e3f838132e
commit c8c30ffe84
5 files changed
+41 -12

No files matched your search

+16 -7
View File
@@ -3,11 +3,11 @@ import config
def formatting_path(path: str) -> str:
path = path.strip()
path = path.replace("\\", "/")
if path[-1] != "/":
path += "/"
return path
path = path.strip()
path = path.replace("\\", "/")
if path[-1] != "/":
path += "/"
return path
def get_exe_dir():
if getattr(sys, "frozen", False):
@@ -30,7 +30,7 @@ def get_config(config_key: str):
config.configdir_path = formatting_path(configdir_path)
config_path = config.configdir_path + config_key
if not (os.path.isfile(config_path)):
return None
return None
with open(config_path, "r", encoding="utf-8") as conf:
conf_v = conf.read().strip()
return conf_v
@@ -39,4 +39,13 @@ def get_config(config_key: str):
def safe_format(fmt_str: str, *args) -> str:
try:
return fmt_str.format(*args)
except: return "__langerr__"
except: return "__langerr__"
def add_unit(num: int) -> str:
for unit in config.unit_list:
if num >= 1024:
num //= 1024
else:
num = str(num)
break
return num+unit