This repository was archived by the owner on Apr 18, 2023. It is now read-only.
forked from Secksdendfordff/Anime4K-Encoder-4.0.1-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
113 lines (93 loc) · 2.56 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os
from datetime import datetime
from shutil import which
__current_version__ = '1.2.0'
def credz():
"""
Print credits
"""
print("___________________________________")
print(" _ _ _ _ _ __")
print(" /_\ _ _ (_)_ __ ___| | || |/ /")
print(" / _ \| ' \| | ' \/ -_)_ _| ' < ")
print("/_/ \_\_||_|_|_|_|_\___| |_||_|\_\\")
print("___________________________________")
print(" Upscale your favorite anime! ")
print(" Made by ThoughtfulDev ")
print(" Updated by Secksdendfordff ")
print(" and KingFaris10 ")
print("\n")
def is_tool(name: str) -> bool:
"""
Returns:
true if the specified tool name is installed
"""
return which(name) is not None
def current_date() -> str:
"""
Returns:
the current date in the format: YYYY-MM-dd HH-MM-SS
"""
return datetime.today().strftime('%Y-%m-%d %H:%M:%S')
def lang_long_to_short(lang: str) -> str:
if lang in reversed_lang_mapping:
return reversed_lang_mapping[lang]
else:
return "und"
def lang_short_to_long(lang: str) -> str:
if lang in language_mapping:
return language_mapping[lang]
else:
return "Unknown"
language_mapping = {
"eng": "English",
"ja": "Japanese",
"jp": "Japanese",
"jap": "Japanese",
"jpn": "Japanese",
"ger": "German",
"kor": "Korean",
"por": "Portuguese",
"spa": "Spanish",
"ita": "Italian",
"pol": "Polish",
"hin": "Hindi",
"chi": "Chinese"
}
reversed_lang_mapping = {
"English": "eng",
"Japanese": "jpn",
"German": "ger",
"Korean": "kor",
"Portuguese": "por",
"Spanish": "spa",
"Italian": "ita",
"Polish": "pol",
"Hindi": "hin",
"Chinese": "chi"
}
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
def str2bool(v) -> bool:
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
def str2dict(v) -> dict:
if v is None:
return {}
if isinstance(v, dict):
return v
v = str(v)
dictionary = {}
for entry in v.split(","):
if "=" not in entry:
raise argparse.ArgumentTypeError(
'Invalid entry, must follow key=value')
entry_split = entry.split("=")
dictionary[entry_split[0]] = entry_split[1]
return dictionary