xenoslib 0.4.0__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xenoslib-0.4.0/xenoslib.egg-info → xenoslib-0.4.2}/PKG-INFO +1 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/__init__.py +1 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/about.py +1 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/base.py +2 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/time_utils.py +37 -33
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/tools/config_loader.py +7 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2/xenoslib.egg-info}/PKG-INFO +1 -1
- {xenoslib-0.4.0 → xenoslib-0.4.2}/LICENSE +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/README.md +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/setup.cfg +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/setup.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/__main__.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/dev.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/extend.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/linux.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/mail.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/mock.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/onedrive.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/tools/__init__.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/win_trayicon.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib/windows.py +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib.egg-info/SOURCES.txt +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib.egg-info/dependency_links.txt +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib.egg-info/requires.txt +0 -0
- {xenoslib-0.4.0 → xenoslib-0.4.2}/xenoslib.egg-info/top_level.txt +0 -0
|
@@ -302,6 +302,7 @@ class SingletonWithArgs:
|
|
|
302
302
|
|
|
303
303
|
class ArgMethodBase:
|
|
304
304
|
"""auto generator arguments by static methods"""
|
|
305
|
+
result = True
|
|
305
306
|
|
|
306
307
|
def __init__(self, epilog=None):
|
|
307
308
|
"""initialize arguments parser"""
|
|
@@ -324,7 +325,7 @@ class ArgMethodBase:
|
|
|
324
325
|
elif self.__run_command__(**vars(args)) is False:
|
|
325
326
|
print(color("ERROR", "RED"), file=sys.stderr)
|
|
326
327
|
exit(-1)
|
|
327
|
-
|
|
328
|
+
elif self.result:
|
|
328
329
|
print(color("OK", "GREEN"), file=sys.stderr)
|
|
329
330
|
|
|
330
331
|
def __run_command__(self, command, **args):
|
|
@@ -10,68 +10,72 @@ from datetime import datetime
|
|
|
10
10
|
|
|
11
11
|
logger = logging.getLogger(__name__)
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
# 添加多语言支持
|
|
14
15
|
def get_system_language():
|
|
15
16
|
"""获取系统语言环境"""
|
|
16
|
-
lang = os.getenv(
|
|
17
|
-
return lang if lang and
|
|
17
|
+
lang = os.getenv("LANG", "").split(".")[0]
|
|
18
|
+
return lang if lang and "_" in lang else "en_US"
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
# 创建翻译字典
|
|
20
22
|
TRANSLATIONS = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
"zh_CN": {
|
|
24
|
+
"days": ("天", "天"),
|
|
25
|
+
"hours": ("小时", "小时"),
|
|
26
|
+
"minutes": ("分钟", "分钟"),
|
|
27
|
+
"seconds": ("秒", "秒"),
|
|
28
|
+
"updated": "最近更新",
|
|
29
|
+
"ago": "前",
|
|
30
|
+
"file_error": "获取文件信息失败",
|
|
31
|
+
},
|
|
32
|
+
"en_US": {
|
|
33
|
+
"days": ("day", "days"),
|
|
34
|
+
"hours": ("hour", "hours"),
|
|
35
|
+
"minutes": ("minute", "minutes"),
|
|
36
|
+
"seconds": ("second", "seconds"),
|
|
37
|
+
"updated": "last updated",
|
|
38
|
+
"ago": "ago",
|
|
39
|
+
"file_error": "Failed to get file info",
|
|
29
40
|
},
|
|
30
|
-
'en_US': {
|
|
31
|
-
'days': ('day', 'days'),
|
|
32
|
-
'hours': ('hour', 'hours'),
|
|
33
|
-
'minutes': ('minute', 'minutes'),
|
|
34
|
-
'seconds': ('second', 'seconds'),
|
|
35
|
-
'updated': 'last updated',
|
|
36
|
-
'ago': 'ago',
|
|
37
|
-
'file_error': 'Failed to get file info'
|
|
38
|
-
}
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
|
|
41
44
|
def timedelta_to_human_readable(delta, lang=None):
|
|
42
45
|
"""将时间差转换为人类可读格式(支持中英双语)"""
|
|
43
46
|
if lang is None:
|
|
44
47
|
lang = get_system_language()
|
|
45
|
-
|
|
46
|
-
trans = TRANSLATIONS.get(lang, TRANSLATIONS[
|
|
48
|
+
|
|
49
|
+
trans = TRANSLATIONS.get(lang, TRANSLATIONS["en_US"])
|
|
47
50
|
days = delta.days
|
|
48
51
|
hours, remainder = divmod(delta.seconds, 3600)
|
|
49
52
|
minutes, seconds = divmod(remainder, 60)
|
|
50
53
|
|
|
51
54
|
time_units = {
|
|
52
|
-
"days": (days, trans[
|
|
53
|
-
"hours": (hours, trans[
|
|
54
|
-
"minutes": (minutes, trans[
|
|
55
|
-
"seconds": (seconds, trans[
|
|
55
|
+
"days": (days, trans["days"]),
|
|
56
|
+
"hours": (hours, trans["hours"]),
|
|
57
|
+
"minutes": (minutes, trans["minutes"]),
|
|
58
|
+
"seconds": (seconds, trans["seconds"]),
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
for unit, (value, labels) in time_units.items():
|
|
59
62
|
if value > 0:
|
|
60
63
|
# 处理英文单复数
|
|
61
|
-
if lang.startswith(
|
|
64
|
+
if lang.startswith("en_") and value > 1:
|
|
62
65
|
return f"{value} {labels[1]}"
|
|
63
|
-
return f"{value}{labels[0]}" if lang.startswith(
|
|
64
|
-
|
|
66
|
+
return f"{value}{labels[0]}" if lang.startswith("zh_") else f"{value} {labels[0]}"
|
|
67
|
+
|
|
65
68
|
# 默认返回0秒
|
|
66
|
-
zero_label = "0" + trans[
|
|
69
|
+
zero_label = "0" + trans["seconds"][0] if lang.startswith("zh_") else f"0 {trans['seconds'][1]}"
|
|
67
70
|
return zero_label
|
|
68
71
|
|
|
72
|
+
|
|
69
73
|
def log_file_update_time(lang=None):
|
|
70
74
|
"""显示调用文件最近更新时间(支持中英双语)"""
|
|
71
75
|
if lang is None:
|
|
72
76
|
lang = get_system_language()
|
|
73
|
-
trans = TRANSLATIONS.get(lang, TRANSLATIONS[
|
|
74
|
-
|
|
77
|
+
trans = TRANSLATIONS.get(lang, TRANSLATIONS["en_US"])
|
|
78
|
+
|
|
75
79
|
try:
|
|
76
80
|
stack = inspect.stack()
|
|
77
81
|
for frame_info in stack:
|
|
@@ -80,11 +84,11 @@ def log_file_update_time(lang=None):
|
|
|
80
84
|
break
|
|
81
85
|
else:
|
|
82
86
|
file_path = __file__
|
|
83
|
-
|
|
87
|
+
|
|
84
88
|
mtime = datetime.fromtimestamp(os.path.getmtime(file_path))
|
|
85
89
|
delta_str = timedelta_to_human_readable(datetime.now() - mtime, lang)
|
|
86
90
|
filename = os.path.basename(file_path)
|
|
87
|
-
|
|
91
|
+
|
|
88
92
|
# 双语日志输出
|
|
89
93
|
log_msg = (
|
|
90
94
|
f"{filename} {trans['updated']}: "
|
|
@@ -244,7 +244,13 @@ class SectionProxy:
|
|
|
244
244
|
|
|
245
245
|
def __repr__(self):
|
|
246
246
|
"""String representation of the section's configuration."""
|
|
247
|
-
return yaml.dump(self.
|
|
247
|
+
return yaml.dump(self.to_dict())
|
|
248
|
+
|
|
249
|
+
def __contains__(self, key):
|
|
250
|
+
return key in self.self.to_dict()
|
|
251
|
+
|
|
252
|
+
def to_dict(self):
|
|
253
|
+
return self._loader._raw_config[self._section]
|
|
248
254
|
|
|
249
255
|
|
|
250
256
|
if __name__ == "__main__":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|