mirror of
https://github.com/xzb23/check_duplicate_files.git
synced 2026-11-24 18:45:31 +08:00
添加I18n支持
This commit is contained in:
7 files changed
+102
-17
No files matched your search
@@ -1,5 +1,5 @@
|
||||
from _in_package import *
|
||||
from config import *
|
||||
import config
|
||||
|
||||
|
||||
def formatting_path(path: str) -> str:
|
||||
@@ -7,4 +7,36 @@ def formatting_path(path: str) -> str:
|
||||
path = path.replace("\\", "/")
|
||||
if path[-1] != "/":
|
||||
path += "/"
|
||||
return path
|
||||
return path
|
||||
|
||||
def get_exe_dir():
|
||||
if getattr(sys, "frozen", False):
|
||||
exe_dir = os.path.dirname(os.path.abspath(sys.executable))
|
||||
else:
|
||||
exe_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
return formatting_path(exe_dir)
|
||||
|
||||
def get_config(config_key: str):
|
||||
if config.configdir_path == None:
|
||||
match platform.system():
|
||||
case "Linux":
|
||||
if os.path.isfile(config.exe_dir + "conf.dir"):
|
||||
with open(config.exe_dir + "conf.dir") as cpf:
|
||||
configdir_path = cpf.read().strip()
|
||||
else:
|
||||
configdir_path = "/etc/check_duplicate_files/"
|
||||
case "Windows":
|
||||
configdir_path = config.exe_dir + "conf.d/"
|
||||
config.configdir_path = formatting_path(configdir_path)
|
||||
config_path = config.configdir_path + config_key
|
||||
if not (os.path.isfile(config_path)):
|
||||
return None
|
||||
with open(config_path, "r", encoding="utf-8") as conf:
|
||||
conf_v = conf.read().strip()
|
||||
return conf_v
|
||||
|
||||
|
||||
def safe_format(fmt_str: str, *args) -> str:
|
||||
try:
|
||||
return fmt_str.format(*args)
|
||||
except: return "__langerr__"
|
||||
Reference in new issue
Block a user