-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
61 lines (45 loc) · 2.37 KB
/
main.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
from Source.Core.SystemObjects import SystemObjects
from Source.CLI.Descriptions import CommandsList
from Source.CLI.Commands import *
from dublib.Methods.System import CheckPythonMinimalVersion
from dublib.Methods.Filesystem import MakeRootDirectories
from dublib.CLI.Terminalyzer import Terminalyzer
import sys
#==========================================================================================#
# >>>>> ИНИЦИАЛИЗАЦИЯ <<<<< #
#==========================================================================================#
CheckPythonMinimalVersion(3, 10)
MakeRootDirectories(["Parsers"])
#==========================================================================================#
# >>>>> НАСТРОЙКА ОБРАБОТЧИКА КОМАНД <<<<< #
#==========================================================================================#
Analyzer = Terminalyzer()
Objects = SystemObjects()
Analyzer.enable_help(True)
CommandDataStruct = Analyzer.check_commands(CommandsList)
Objects.logger.info("====== Preparing to starting ======")
Objects.logger.info(f"Starting with Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} on {sys.platform}.")
Objects.logger.info("Command: \"" + " ".join(sys.argv[1:len(sys.argv)]) + "\".")
if CommandDataStruct == None:
Objects.logger.set_rule(3)
Objects.logger.close()
print("Unknown command!")
exit(0)
elif CommandDataStruct.name in ("help", "list", "tagger"): Objects.LIVE_MODE = True
if not Objects.LIVE_MODE:
Objects.logger.templates.title(SystemObjects.VERSION)
if "f" in CommandDataStruct.flags:
Objects.FORCE_MODE = True
Objects.logger.info("Force mode: ON.")
Objects.logger.templates.option_status("Force mode", Objects.FORCE_MODE)
Objects.logger.templates.header("PROCESSING")
#==========================================================================================#
# >>>>> ОБРАБОТКА КОММАНД <<<<< #
#==========================================================================================#
try: exec(f"com_{CommandDataStruct.name}(Objects, CommandDataStruct)")
except KeyboardInterrupt: exit(0)
#==========================================================================================#
# >>>>> ЗАВЕРШЕНИЕ РАБОТЫ <<<<< #
#==========================================================================================#
Objects.logger.close()
exit(Objects.EXIT_CODE)