Skip to content

Commit 7dd4ab6

Browse files
Log name format changed, added some strings of localization, menu fixes
1 parent 6efce6b commit 7dd4ab6

File tree

7 files changed

+40
-28
lines changed

7 files changed

+40
-28
lines changed

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
while True:
2727
try:
28-
clear()
2928
handler = menu.choice()
3029
if handler is not None:
3130
start_time = time.time()
3231
with logger.catch():
3332
handler()
3433
logger.opt(colors=True).info(f'<green>{locale.done % (time.time() - start_time)}</green>')
3534
input(locale.to_continue)
35+
clear()
3636
except KeyboardInterrupt:
3737
if Console.question(locale.want_exit):
3838
clear()

system/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run(command: str, output_path: str = null_output):
2020
logger.exception(e)
2121

2222
def clear():
23-
run('cls')
23+
os.system('cls')
2424
else:
2525
def clear():
26-
run('clear')
26+
os.system('clear')

system/languages/en-EU.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"crt_workspace": "Creating workspace directories...",
88
"verifying": "Verifying installation...",
99
"installed": "%s was successfully installed!",
10-
"update_done": "The update was downloaded successfully! Please move all files from directory %s to script directory",
10+
"update_done": "The update was downloaded successfully! Please move all files from directory%s to script directory",
1111
"not_installed": "%s wasn't installed!",
1212
"clear_qu": "Are you sure you want to clear the dirs?",
1313
"done": "Completed in %.2f seconds!",
14+
"done_qu": "Done?",
1415
"choice": "Your choice: ",
1516
"to_continue": "Press Enter to continue...",
1617
"experimental": "Experimental feature",
@@ -86,5 +87,7 @@
8687
"stp": "Installing...",
8788
"margin_qu": "Consider edge margins?",
8889
"enabled": "Enabled",
89-
"disabled": "Disabled"
90+
"disabled": "Disabled",
91+
92+
"install_to_unlock": "Install \"%s\" to unlock more functions!"
9093
}

system/languages/ru-RU.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"crt_workspace": "Создаются рабочие папки...",
88
"verifying": "Проверка установки...",
99
"installed": "%s успешно установлен!",
10-
"update_done": "Обновление успешно скачалось! Пожалуйста, переместите все файлы из каталога %s в каталог скрипта",
10+
"update_done": "Обновление успешно скачалось! Пожалуйста, переместите все файлы из каталога%s в каталог скрипта",
1111
"not_installed": "%s не установлен!",
1212
"clear_qu": "Вы действительно хотите очистить папки?",
1313
"done": "Выполнено за %.2f секунд!",
14+
"done_qu": "Сделано?",
1415
"choice": "ВАШЕ ДЕЙСТВИЕ: ",
1516
"to_continue": "Нажмите Enter для продолжения...",
1617
"experimental": "Экспериментальная функция",
@@ -86,5 +87,7 @@
8687
"stp": "Установка...",
8788
"margin_qu": "Учитывать отступы от краев?",
8889
"enabled": "Включено",
89-
"disabled": "Выключено"
90+
"disabled": "Выключено",
91+
92+
"install_to_unlock": "Установите \"%s\" чтобы открыть больше функций!"
9093
}

system/lib/__init__.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from system import clear
55
from system.lib.config import config
66
from system.lib.console import Console
7-
from system.lib.features.csv.compress import compress_csv
8-
from system.lib.features.csv.decompress import decompress_csv
97
from system.lib.features.directories import clear_directories
108
from system.lib.features.initialization import initialize
119
from system.lib.features.update.check import check_update, check_for_outdated, get_tags
@@ -16,13 +14,13 @@
1614

1715
logger.remove()
1816
logger.add(
19-
'./logs/info/{time:YYYY-dd-MM_HH-mm-ss}.log',
17+
'./logs/info/{time:YYYY-dd-MM}.log',
2018
format='[{time:HH:mm:ss}] [{level}]: {message}',
2119
encoding="utf8",
2220
level='INFO'
2321
)
2422
logger.add(
25-
'./logs/errors/{time:YYYY-dd-MM_HH-mm-ss}.log',
23+
'./logs/errors/{time:YYYY-dd-MM}.log',
2624
format='[{time:HH:mm:ss}] [{level}]: {message}',
2725
backtrace=True,
2826
diagnose=True,
@@ -45,8 +43,8 @@
4543
config.dump()
4644

4745
if config.has_update:
48-
logger.opt(colors=True).info(f'<green>{locale.update_done}</green>')
49-
if Console.question(locale.done[:-1] + '?'):
46+
logger.opt(colors=True).info(f'<green>{locale.update_done % ""}</green>')
47+
if Console.question(locale.done_qu):
5048
latest_tag = get_tags('vorono4ka', 'xcoder')[0]
5149
latest_tag_name = latest_tag['name'][1:]
5250

@@ -56,8 +54,8 @@
5654
config.dump()
5755
else:
5856
exit()
59-
except ImportError as exception:
60-
logger.error(exception)
57+
except ImportError:
58+
pass
6159

6260

6361
@logger.catch()
@@ -68,6 +66,9 @@ def refill_menu():
6866
import sc_compression
6967
del sc_compression
7068

69+
from system.lib.features.csv.compress import compress_csv
70+
from system.lib.features.csv.decompress import decompress_csv
71+
7172
try:
7273
import PIL
7374
del PIL
@@ -104,8 +105,8 @@ def refill_menu():
104105
lambda: sc1_encode(True)
105106
))
106107
menu.add_category(sc_category)
107-
except ImportError as e:
108-
logger.exception(e)
108+
except ImportError:
109+
logger.warning(locale.install_to_unlock % 'PILLOW')
109110

110111
csv_category = Menu.Category(1, locale.csv_label)
111112
csv_category.add(Menu.Item(
@@ -119,8 +120,8 @@ def refill_menu():
119120
compress_csv
120121
))
121122
menu.add_category(csv_category)
122-
except ImportError as exception:
123-
logger.exception(exception)
123+
except ImportError:
124+
logger.warning(locale.install_to_unlock % 'sc-compression')
124125

125126
other = Menu.Category(10, locale.other_features_label)
126127
try:
@@ -132,8 +133,8 @@ def refill_menu():
132133
locale.version % config.version,
133134
check_update
134135
))
135-
except ImportError as exception:
136-
logger.exception(exception)
136+
except ImportError:
137+
logger.warning(locale.install_to_unlock % 'requests')
137138

138139
other.add(Menu.Item(
139140
locale.check_for_outdated,

system/lib/menu.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def print_category(text):
1717
return print(colorama.Back.GREEN + colorama.Fore.BLACK + text + ' ' * (10 - len(text)) + colorama.Style.RESET_ALL)
1818

1919

20+
def print_line(console_width):
21+
print((console_width - 1) * '-')
22+
23+
2024
class Menu:
2125
class Item:
2226
def __init__(self, name, description=None, handler=None):
@@ -46,23 +50,21 @@ def add_category(self, category):
4650
return category
4751

4852
def choice(self):
49-
config.load()
50-
5153
console_width = shutil.get_terminal_size().columns
5254
print((
5355
colorama.Back.BLACK + colorama.Fore.GREEN +
5456
locale.xcoder_header % config.version +
5557
colorama.Style.RESET_ALL
56-
).center(console_width + 14))
57-
print('github.com/Vorono4ka/XCoder'.center(console_width))
58-
print(console_width * '-')
58+
).center(console_width + 12))
59+
print('github.com/Vorono4ka/XCoder'.center(console_width - 1))
60+
print_line(console_width)
5961

6062
for category in self.categories:
6163
print_category(category.name)
6264
for item_index in range(len(category.items)):
6365
item = category.items[item_index]
6466
print_feature(f' {category.id * 10 + item_index + 1} {item.name}', item.description, console_width)
65-
print(console_width * '-')
67+
print_line(console_width)
6668

6769
choice = input(locale.choice)
6870
try:
@@ -71,7 +73,7 @@ def choice(self):
7173
return None
7274
except ValueError:
7375
return None
74-
print(console_width * '-')
76+
print_line(console_width)
7577

7678
category_id = choice // 10
7779
item_index = choice % 10

system/localization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def __init__(self):
1515
self.not_installed = None
1616
self.clear_qu = None
1717
self.done = None
18+
self.done_qu = None
1819
self.choice = None
1920
self.to_continue = None
2021
self.experimental = None
@@ -94,6 +95,8 @@ def __init__(self):
9495
self.enabled = None
9596
self.disabled = None
9697

98+
self.install_to_unlock = None
99+
97100
def load(self, language: str):
98101
language_filepath = './system/languages/' + language + '.json'
99102
english_language_filepath = './system/languages/en-EU.json'

0 commit comments

Comments
 (0)