mirror of
https://github.com/xzb23/check_duplicate_files.git
synced 2026-11-24 10:25:26 +08:00
优化提示信息
This commit is contained in:
5 files changed
+41
-12
No files matched your search
+2
-1
@@ -6,4 +6,5 @@ build
|
|||||||
*.backup
|
*.backup
|
||||||
/.venv
|
/.venv
|
||||||
/.vscode
|
/.vscode
|
||||||
/conf.d
|
/conf.d
|
||||||
|
/test.py
|
||||||
@@ -51,8 +51,22 @@ def print_info(hash_to_files_list: list = runing_data.hash_to_files):
|
|||||||
for fp in runing_data.hash_to_files[t]:
|
for fp in runing_data.hash_to_files[t]:
|
||||||
print("\t", fp)
|
print("\t", fp)
|
||||||
print()
|
print()
|
||||||
print(common.safe_format(config.l10n_data.get_text("info_print_info_duplicate_msg"), (size_total-size_if_one)//1024, size_total//1024))
|
if size_total == size_if_one:
|
||||||
print(common.safe_format(config.l10n_data.get_text("info_print_info_if_size-flag_duplicate_msg"), config.flag_size, (print_size_total-print_size_if_one)//1024, print_size_total//1024))
|
print(config.l10n_data.get_text("info_print_info_not_duplicate_msg"))
|
||||||
|
|
||||||
|
size_duplicate = size_total - size_if_one
|
||||||
|
print_size_duplicate = print_size_total - print_size_if_one
|
||||||
|
|
||||||
|
size_total = common.add_unit(size_total)
|
||||||
|
size_duplicate = common.add_unit(size_duplicate)
|
||||||
|
print_size_total = common.add_unit(print_size_total)
|
||||||
|
print_size_duplicate = common.add_unit(print_size_duplicate)
|
||||||
|
print(config.l10n_data.get_text("info_print_info_duplicate_msg"), end="\t")
|
||||||
|
print(f"\t{size_duplicate} / {size_total}")
|
||||||
|
|
||||||
|
if config.flag_size > 0:
|
||||||
|
print(common.safe_format(config.l10n_data.get_text("info_print_info_if_size-flag_duplicate_msg"), config.flag_size), end="\t")
|
||||||
|
print(f"\t{print_size_duplicate} / {print_size_total}")
|
||||||
|
|
||||||
|
|
||||||
def reg_opts():
|
def reg_opts():
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import config
|
|||||||
|
|
||||||
|
|
||||||
def formatting_path(path: str) -> str:
|
def formatting_path(path: str) -> str:
|
||||||
path = path.strip()
|
path = path.strip()
|
||||||
path = path.replace("\\", "/")
|
path = path.replace("\\", "/")
|
||||||
if path[-1] != "/":
|
if path[-1] != "/":
|
||||||
path += "/"
|
path += "/"
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def get_exe_dir():
|
def get_exe_dir():
|
||||||
if getattr(sys, "frozen", False):
|
if getattr(sys, "frozen", False):
|
||||||
@@ -30,7 +30,7 @@ def get_config(config_key: str):
|
|||||||
config.configdir_path = formatting_path(configdir_path)
|
config.configdir_path = formatting_path(configdir_path)
|
||||||
config_path = config.configdir_path + config_key
|
config_path = config.configdir_path + config_key
|
||||||
if not (os.path.isfile(config_path)):
|
if not (os.path.isfile(config_path)):
|
||||||
return None
|
return None
|
||||||
with open(config_path, "r", encoding="utf-8") as conf:
|
with open(config_path, "r", encoding="utf-8") as conf:
|
||||||
conf_v = conf.read().strip()
|
conf_v = conf.read().strip()
|
||||||
return conf_v
|
return conf_v
|
||||||
@@ -39,4 +39,13 @@ def get_config(config_key: str):
|
|||||||
def safe_format(fmt_str: str, *args) -> str:
|
def safe_format(fmt_str: str, *args) -> str:
|
||||||
try:
|
try:
|
||||||
return fmt_str.format(*args)
|
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
|
||||||
@@ -10,4 +10,8 @@ lang: str = "zh_cn"
|
|||||||
l10n_data: I18n.I18nText
|
l10n_data: I18n.I18nText
|
||||||
|
|
||||||
configdir_path: str = None
|
configdir_path: str = None
|
||||||
|
|
||||||
|
unit_list = ["Byte", "KiB", "MiB", "GiB", "TiB"]
|
||||||
|
|
||||||
|
|
||||||
import I18n
|
import I18n
|
||||||
+3
-2
@@ -2,5 +2,6 @@ help_fsize = 只打印文件大小大于fsize Byte的重复文件
|
|||||||
tip_traverse_dir = 正在遍历文件ing...
|
tip_traverse_dir = 正在遍历文件ing...
|
||||||
info_traverse_dir = 完成 总计 {} 个文件
|
info_traverse_dir = 完成 总计 {} 个文件
|
||||||
tip_hash_files_from_glist = 正在计算文件散列ing...
|
tip_hash_files_from_glist = 正在计算文件散列ing...
|
||||||
info_print_info_duplicate_msg = 重复部分占用/总占用: {}KiB / {}KiB
|
info_print_info_duplicate_msg = 重复部分占用/总占用:
|
||||||
info_print_info_if_size-flag_duplicate_msg = 占用大于 {} Byte 的文件中,重复部分占用/总占用: {}KiB / {}KiB
|
info_print_info_if_size-flag_duplicate_msg = 占用大于 {} Byte 的文件中,重复部分占用/总占用:
|
||||||
|
info_print_info_not_duplicate_msg = 没有找到重复文件
|
||||||
Reference in new issue
Block a user