dublib 0.30.0__tar.gz → 0.30.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.
- {dublib-0.30.0 → dublib-0.30.2}/PKG-INFO +2 -2
- {dublib-0.30.0 → dublib-0.30.2}/pyproject.toml +3 -10
- {dublib-0.30.0 → dublib-0.30.2}/pyproject.toml.orig +3 -10
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/parser/__init__.py +76 -22
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/parser/entitites.py +32 -9
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/polyglot/html.py +3 -3
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/telebot_utils/cache.py +25 -31
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/validators/types.py +0 -2
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/__init__.py +8 -12
- {dublib-0.30.0 → dublib-0.30.2}/LICENSE +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/README.md +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/progress_indicator.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/readline.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/templates/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/templates/bus.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/group.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/identificator.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/model.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/parameters.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/commands/positions.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/helper/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/helper/options.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/terminalyzer/parser/typing.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/text_styler/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/text_styler/codes.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/text_styler/escapes.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/cli/text_styler/fast_styler.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/core.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/bus/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/bus/enums.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/bus/messages.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/configurator.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/get_text.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/engine/patcher.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/cli/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/cli/terminalyzer/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/cli/terminalyzer/groups.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/cli/terminalyzer/parameters.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/cli/terminalyzer/positions.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/engine/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/engine/bus.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/telebot_utils.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/validators.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/exceptions/web_requestor.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/data/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/data/dictionary.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/data/string.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/decorators.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/filesystem/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/filesystem/json.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/filesystem/text.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/filesystem/yaml.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/functions/system.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/polyglot/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/polyglot/markdown.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/py.typed +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/telebot_utils/master/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/telebot_utils/master/decorators.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/telebot_utils/users.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/validators/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/validators/base.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/config/__init__.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/config/authorization.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/config/constants.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/config/headers.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/enums.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/proxy.py +0 -0
- {dublib-0.30.0 → dublib-0.30.2}/src/dublib/web_requestor/response.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dublib
|
|
3
|
-
Version: 0.30.
|
|
3
|
+
Version: 0.30.2
|
|
4
4
|
Summary: Коллекция полезных модулей от DUB1401.
|
|
5
5
|
Author: DUB1401
|
|
6
6
|
Author-email: DUB1401 <vlad.milosta@outlook.com>
|
|
@@ -52,10 +52,10 @@ Requires-Dist: validators
|
|
|
52
52
|
Requires-Dist: watchfiles
|
|
53
53
|
Requires-Dist: gnureadline>=8.3.3 ; sys_platform == 'linux'
|
|
54
54
|
Requires-Dist: pyreadline3 ; sys_platform == 'win32'
|
|
55
|
-
Requires-Dist: mypy ; extra == 'dev'
|
|
56
55
|
Requires-Dist: myst-parser ; extra == 'dev'
|
|
57
56
|
Requires-Dist: pytest ; extra == 'dev'
|
|
58
57
|
Requires-Dist: ruff ; extra == 'dev'
|
|
58
|
+
Requires-Dist: ty ; extra == 'dev'
|
|
59
59
|
Requires-Dist: sphinx ; extra == 'dev'
|
|
60
60
|
Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
|
|
61
61
|
Requires-Dist: apscheduler ; extra == 'telebot'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["uv-build>=0.12.
|
|
2
|
+
requires = ["uv-build>=0.12.10,<0.13.0"]
|
|
3
3
|
build-backend = "uv_build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dublib"
|
|
7
|
-
version = "0.30.
|
|
7
|
+
version = "0.30.2"
|
|
8
8
|
description = "Коллекция полезных модулей от DUB1401."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -50,10 +50,10 @@ telebot = [
|
|
|
50
50
|
"pyTelegramBotAPI",
|
|
51
51
|
]
|
|
52
52
|
dev = [
|
|
53
|
-
"mypy",
|
|
54
53
|
"myst_parser",
|
|
55
54
|
"pytest",
|
|
56
55
|
"ruff",
|
|
56
|
+
"ty",
|
|
57
57
|
"Sphinx",
|
|
58
58
|
"sphinx-rtd-theme",
|
|
59
59
|
]
|
|
@@ -64,13 +64,6 @@ Documentation = "https://github.com/DUB1401/dublib/tree/main/docs"
|
|
|
64
64
|
"Bug Tracker" = "https://github.com/DUB1401/dublib/issues"
|
|
65
65
|
Changelog = "https://github.com/DUB1401/dublib/releases"
|
|
66
66
|
|
|
67
|
-
[tool.mypy]
|
|
68
|
-
ignore_missing_imports = true
|
|
69
|
-
check_untyped_defs = true
|
|
70
|
-
non_interactive = true
|
|
71
|
-
follow_imports = "silent"
|
|
72
|
-
files = ["src"]
|
|
73
|
-
|
|
74
67
|
[tool.ruff]
|
|
75
68
|
include = [
|
|
76
69
|
"src/*",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["uv-build>=0.12.
|
|
2
|
+
requires = ["uv-build>=0.12.10,<0.13.0"]
|
|
3
3
|
build-backend = "uv_build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dublib"
|
|
7
|
-
version = "0.30.
|
|
7
|
+
version = "0.30.2"
|
|
8
8
|
description = "Коллекция полезных модулей от DUB1401."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "DUB1401", email = "vlad.milosta@outlook.com"}
|
|
@@ -47,10 +47,10 @@ telebot = [
|
|
|
47
47
|
"pyTelegramBotAPI"
|
|
48
48
|
]
|
|
49
49
|
dev = [
|
|
50
|
-
"mypy",
|
|
51
50
|
"myst_parser",
|
|
52
51
|
"pytest",
|
|
53
52
|
"ruff",
|
|
53
|
+
"ty",
|
|
54
54
|
"Sphinx",
|
|
55
55
|
"sphinx-rtd-theme"
|
|
56
56
|
]
|
|
@@ -61,13 +61,6 @@ Documentation = "https://github.com/DUB1401/dublib/tree/main/docs"
|
|
|
61
61
|
"Bug Tracker" = "https://github.com/DUB1401/dublib/issues"
|
|
62
62
|
Changelog = "https://github.com/DUB1401/dublib/releases"
|
|
63
63
|
|
|
64
|
-
[tool.mypy]
|
|
65
|
-
ignore_missing_imports = true
|
|
66
|
-
check_untyped_defs = true
|
|
67
|
-
non_interactive = true
|
|
68
|
-
follow_imports = "silent"
|
|
69
|
-
files = ["src"]
|
|
70
|
-
|
|
71
64
|
[tool.ruff]
|
|
72
65
|
include = ["src/*", "tests/*"]
|
|
73
66
|
|
|
@@ -11,6 +11,7 @@ from .entitites import (
|
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from ..commands.model import CommandModel
|
|
14
|
+
from ..commands.positions import Position
|
|
14
15
|
|
|
15
16
|
__all__ = ["CommandParser"]
|
|
16
17
|
|
|
@@ -99,9 +100,45 @@ class CommandParser:
|
|
|
99
100
|
|
|
100
101
|
self.__base_parameters.append(entity)
|
|
101
102
|
|
|
102
|
-
def
|
|
103
|
+
def __catch_argument_for_positions(self, parameter: str, index: int):
|
|
103
104
|
"""
|
|
104
|
-
Пытается
|
|
105
|
+
Пытается назначить аргумент на разблокированные позиции.
|
|
106
|
+
|
|
107
|
+
:param parameter: Значение параметра.
|
|
108
|
+
:type parameter: str
|
|
109
|
+
:param index: Индекс параметра.
|
|
110
|
+
:type index: int
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
for position in self.__model.positions:
|
|
114
|
+
|
|
115
|
+
if self.__is_position_locked(position): continue
|
|
116
|
+
|
|
117
|
+
if position.argument and self.__positions_parameters[position.name] is None:
|
|
118
|
+
value = position.argument.type.value.parse(parameter)
|
|
119
|
+
self.__lock_position(position.name, index, ArgumentEntity(position.argument, value))
|
|
120
|
+
return
|
|
121
|
+
|
|
122
|
+
def __catch_argument_for_base_position(self, parameter: str, index: int):
|
|
123
|
+
"""
|
|
124
|
+
Пытается назначить аргумент на базовую позицию.
|
|
125
|
+
|
|
126
|
+
:param parameter: Значение параметра.
|
|
127
|
+
:type parameter: str
|
|
128
|
+
:param index: Индекс параметра.
|
|
129
|
+
:type index: int
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
base = self.__model.base
|
|
133
|
+
|
|
134
|
+
for argument in base.arguments:
|
|
135
|
+
value = argument.type.value.parse(parameter)
|
|
136
|
+
self.__add_base_position_parameter(index, ArgumentEntity(argument, value))
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
def __catch_named_parameters_for_base_position(self, parameter: str, index: int):
|
|
140
|
+
"""
|
|
141
|
+
Пытается назначить именованные параметры на базовую позицию.
|
|
105
142
|
|
|
106
143
|
:param parameter: Значение параметра.
|
|
107
144
|
:type parameter: str
|
|
@@ -113,7 +150,7 @@ class CommandParser:
|
|
|
113
150
|
|
|
114
151
|
for flag in base.flags:
|
|
115
152
|
if parameter == flag.name or parameter in flag.aliases:
|
|
116
|
-
self.__add_base_position_parameter(index, FlagEntity(flag
|
|
153
|
+
self.__add_base_position_parameter(index, FlagEntity(flag))
|
|
117
154
|
return
|
|
118
155
|
|
|
119
156
|
for key in base.keys:
|
|
@@ -122,15 +159,10 @@ class CommandParser:
|
|
|
122
159
|
value = key.type.value.parse(self.__parameters[index + 1])
|
|
123
160
|
self.__add_base_position_parameter(index, KeyEntity(key, value))
|
|
124
161
|
return
|
|
125
|
-
|
|
126
|
-
for argument in base.arguments:
|
|
127
|
-
value = argument.type.value.parse(self.__parameters[index])
|
|
128
|
-
self.__add_base_position_parameter(index, ArgumentEntity(argument, value))
|
|
129
|
-
return
|
|
130
162
|
|
|
131
|
-
def
|
|
163
|
+
def __catch_named_parameters_for_positions(self, parameter: str, index: int):
|
|
132
164
|
"""
|
|
133
|
-
Пытается
|
|
165
|
+
Пытается назначить именованные параметры на разблокированные позиции.
|
|
134
166
|
|
|
135
167
|
:param parameter: Значение параметра.
|
|
136
168
|
:type parameter: str
|
|
@@ -139,10 +171,12 @@ class CommandParser:
|
|
|
139
171
|
"""
|
|
140
172
|
|
|
141
173
|
for position in self.__model.positions:
|
|
174
|
+
|
|
175
|
+
if self.__is_position_locked(position): continue
|
|
142
176
|
|
|
143
177
|
for flag in position.flags:
|
|
144
178
|
if parameter == flag.name or parameter in flag.aliases:
|
|
145
|
-
self.__lock_position(position.name, index, FlagEntity(flag
|
|
179
|
+
self.__lock_position(position.name, index, FlagEntity(flag))
|
|
146
180
|
return
|
|
147
181
|
|
|
148
182
|
for key in position.keys:
|
|
@@ -151,11 +185,28 @@ class CommandParser:
|
|
|
151
185
|
value = key.type.value.parse(self.__parameters[index + 1])
|
|
152
186
|
self.__lock_position(position.name, index, KeyEntity(key, value))
|
|
153
187
|
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
188
|
+
|
|
189
|
+
def __get_unlocked_parameters_range(self) -> list[int]:
|
|
190
|
+
"""
|
|
191
|
+
Возвращает список индексов незаблокированных параметров.
|
|
192
|
+
|
|
193
|
+
:return: Список индексов незаблокированных параметров.
|
|
194
|
+
:rtype: list[int]
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
return [index for index in range(len(self.__parameters_locks)) if not self.__parameters_locks[index]]
|
|
198
|
+
|
|
199
|
+
def __is_position_locked(self, position: "Position") -> bool:
|
|
200
|
+
"""
|
|
201
|
+
Проверяет, заблокирована ли позиция.
|
|
202
|
+
|
|
203
|
+
:param position: Позиция.
|
|
204
|
+
:type position: Position
|
|
205
|
+
:return: Возвращает `True`, если позиция заблокирована.
|
|
206
|
+
:rtype: bool
|
|
207
|
+
"""
|
|
208
|
+
|
|
209
|
+
return bool(self.__positions_parameters[position.name])
|
|
159
210
|
|
|
160
211
|
def __lock_position(self, position_name: str, index: int, entity: ArgumentEntity | FlagEntity | KeyEntity):
|
|
161
212
|
"""
|
|
@@ -217,14 +268,17 @@ class CommandParser:
|
|
|
217
268
|
:rtype: CommandEntity
|
|
218
269
|
"""
|
|
219
270
|
|
|
220
|
-
|
|
271
|
+
for index in self.__get_unlocked_parameters_range():
|
|
272
|
+
self.__catch_named_parameters_for_positions(self.__parameters[index], index)
|
|
273
|
+
|
|
274
|
+
for index in self.__get_unlocked_parameters_range():
|
|
275
|
+
self.__catch_named_parameters_for_base_position(self.__parameters[index], index)
|
|
221
276
|
|
|
222
|
-
for index in
|
|
223
|
-
self.
|
|
277
|
+
for index in self.__get_unlocked_parameters_range():
|
|
278
|
+
self.__catch_argument_for_positions(self.__parameters[index], index)
|
|
224
279
|
|
|
225
|
-
for index in
|
|
226
|
-
|
|
227
|
-
self.__catch_parameters_for_base_position(self.__parameters[index], index)
|
|
280
|
+
for index in self.__get_unlocked_parameters_range():
|
|
281
|
+
self.__catch_argument_for_base_position(self.__parameters[index], index)
|
|
228
282
|
|
|
229
283
|
self.__check_important_positions_parameters()
|
|
230
284
|
self.__check_prarameters_bounds()
|
|
@@ -48,23 +48,20 @@ class FlagEntity:
|
|
|
48
48
|
return self.__parameter
|
|
49
49
|
|
|
50
50
|
@property
|
|
51
|
-
def value(self) ->
|
|
52
|
-
"""
|
|
51
|
+
def value(self) -> str:
|
|
52
|
+
"""Основное имя флага."""
|
|
53
53
|
|
|
54
|
-
return self.
|
|
54
|
+
return self.__parameter.name
|
|
55
55
|
|
|
56
|
-
def __init__(self, parameter: "Flag"
|
|
56
|
+
def __init__(self, parameter: "Flag"):
|
|
57
57
|
"""
|
|
58
58
|
Сущность аргумента.
|
|
59
59
|
|
|
60
60
|
:param parameter: Параметр.
|
|
61
61
|
:type parameter: Flag
|
|
62
|
-
:param value: Значение ключа.
|
|
63
|
-
:type value: bool
|
|
64
62
|
"""
|
|
65
63
|
|
|
66
64
|
self.__parameter = parameter
|
|
67
|
-
self.__value = value
|
|
68
65
|
|
|
69
66
|
class KeyEntity:
|
|
70
67
|
"""Сущность ключа."""
|
|
@@ -340,7 +337,7 @@ class CommandEntity:
|
|
|
340
337
|
|
|
341
338
|
:param position_name: Имя позиции.
|
|
342
339
|
:type position_name: str
|
|
343
|
-
:param not_found_error: Указывает, выбрасывать ли исключение, если
|
|
340
|
+
:param not_found_error: Указывает, выбрасывать ли исключение, если позиция не найдена.
|
|
344
341
|
:type not_found_error: bool
|
|
345
342
|
:return: Сущность параметра позиции или `None` при пустой позиции.
|
|
346
343
|
:rtype: ArgumentEntity | FlagEntity | KeyEntity | None
|
|
@@ -356,6 +353,32 @@ class CommandEntity:
|
|
|
356
353
|
|
|
357
354
|
return self.__positions[position_name].content
|
|
358
355
|
|
|
356
|
+
@overload
|
|
357
|
+
def get_position_named_parameter(self, position_name: str, not_found_error: Literal[True] = True) -> FlagEntity | KeyEntity: ...
|
|
358
|
+
@overload
|
|
359
|
+
def get_position_named_parameter(self, position_name: str, not_found_error: Literal[False] = False) -> FlagEntity | KeyEntity | None: ...
|
|
360
|
+
|
|
361
|
+
def get_position_named_parameter(self, position_name: str, not_found_error: bool = False) -> FlagEntity | KeyEntity | None:
|
|
362
|
+
"""
|
|
363
|
+
Возвращает сущность именованного параметра позиции.
|
|
364
|
+
|
|
365
|
+
:param position_name: Имя позиции.
|
|
366
|
+
:type position_name: str
|
|
367
|
+
:param not_found_error: Указывает, выбрасывать ли исключение, если позиция не найдена.
|
|
368
|
+
:type not_found_error: bool
|
|
369
|
+
:return: Сущность именованного параметра позиции или `None` при пустой позиции.
|
|
370
|
+
:rtype: FlagEntity | KeyEntity | None
|
|
371
|
+
:raises PositionNotFoundError: Позиция не найдена.
|
|
372
|
+
:raises TypeError: На позиции находится сущность аргумента.
|
|
373
|
+
"""
|
|
374
|
+
|
|
375
|
+
parameter_entity = self.get_position_parameter(position_name, not_found_error)
|
|
376
|
+
|
|
377
|
+
if isinstance(parameter_entity, ArgumentEntity):
|
|
378
|
+
raise TypeError("Unnamed parameter on position.")
|
|
379
|
+
|
|
380
|
+
return parameter_entity
|
|
381
|
+
|
|
359
382
|
@overload
|
|
360
383
|
def get_position_value[T: SUPPORTED_TYPES](self, position_name: str, expected_type: type[T], important: Literal[True]) -> T: ...
|
|
361
384
|
@overload
|
|
@@ -375,7 +398,7 @@ class CommandEntity:
|
|
|
375
398
|
:type expected_type: type[SUPPORTED_TYPES] | None
|
|
376
399
|
:param important: Указывает, должна ли позиция обязательно иметь значение.
|
|
377
400
|
:type important: bool
|
|
378
|
-
:return: Параметр позиции или `None` при пустой позиции. Для флага возвращает
|
|
401
|
+
:return: Параметр позиции или `None` при пустой позиции. Для флага возвращает основное имя.
|
|
379
402
|
:rtype: SUPPORTED_TYPES | None
|
|
380
403
|
:raises ImportantPositionEmptyError: Для обязательной позиции не задан параметр.
|
|
381
404
|
:raises PositionNotFoundError: Позиция не найдена.
|
|
@@ -38,14 +38,14 @@ class _Validator(HTMLParser):
|
|
|
38
38
|
def error(self, message):
|
|
39
39
|
self.errors.append(f"Parsing error: {message}.")
|
|
40
40
|
|
|
41
|
-
def _ValidateHTML(text: str) -> tuple[str]:
|
|
41
|
+
def _ValidateHTML(text: str) -> tuple[str, ...]:
|
|
42
42
|
"""
|
|
43
43
|
Проводит валидацию структуры HTML.
|
|
44
44
|
|
|
45
45
|
:param text: Обрабатываемый текст с тегами HTML.
|
|
46
46
|
:type text: str
|
|
47
47
|
:return: Набор ошибок валидации. Пустая последовательность при отсутствии ошибок.
|
|
48
|
-
:rtype: tuple[str]
|
|
48
|
+
:rtype: tuple[str, ...]
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
51
|
Parser = _Validator()
|
|
@@ -171,7 +171,7 @@ class HTML:
|
|
|
171
171
|
|
|
172
172
|
return self.__Text
|
|
173
173
|
|
|
174
|
-
def validate(self, raise_exception: bool = False) -> tuple[str]:
|
|
174
|
+
def validate(self, raise_exception: bool = False) -> tuple[str, ...]:
|
|
175
175
|
"""
|
|
176
176
|
Проверяет валидность структуры HTML.
|
|
177
177
|
|
|
@@ -202,105 +202,100 @@ class TeleCache:
|
|
|
202
202
|
# >>>>> ПРИВАТНЫЕ МЕТОДЫ ВЫГРУЗКИ ФАЙЛОВ <<<<< #
|
|
203
203
|
#==========================================================================================#
|
|
204
204
|
|
|
205
|
-
def __Upload_Animation(self, file_path: Path) -> str | None:
|
|
205
|
+
def __Upload_Animation(self, file_path: Path) -> tuple[types.Message, str | None]:
|
|
206
206
|
"""
|
|
207
207
|
Выгружает анимацию.
|
|
208
208
|
|
|
209
209
|
:param file_path: Путь к файлу.
|
|
210
210
|
:type file_path: Path
|
|
211
211
|
:return: ID файла или `None` в случае неудачи.
|
|
212
|
-
:rtype: str | None
|
|
212
|
+
:rtype: tuple[types.Message, str | None]
|
|
213
213
|
:raises TypeError: Неверный тип файла для данного типа вложений.
|
|
214
214
|
"""
|
|
215
215
|
|
|
216
216
|
ChatID = cast(int, self.__ChatID)
|
|
217
|
-
Bot = cast(TeleBot, self.__Bot)
|
|
218
217
|
FileID: str | None = None
|
|
219
218
|
|
|
220
|
-
Message =
|
|
219
|
+
Message = self.__Bot.send_animation(chat_id = ChatID, animation = types.InputFile(file_path))
|
|
221
220
|
if Message.animation: FileID = Message.animation.file_id
|
|
222
221
|
# Некоторые анимации отображаются верно, но распознаются как документы.
|
|
223
222
|
elif Message.document: FileID = Message.document.file_id
|
|
224
223
|
# Выброс исключения при попытке использования полноценного видео в качестве анимации.
|
|
225
224
|
elif Message.video: raise TypeError("Use InputMediaVideo for this file.")
|
|
226
225
|
|
|
227
|
-
return FileID
|
|
226
|
+
return Message, FileID
|
|
228
227
|
|
|
229
|
-
def __Upload_Audio(self, file_path: Path) -> str | None:
|
|
228
|
+
def __Upload_Audio(self, file_path: Path) -> tuple[types.Message, str | None]:
|
|
230
229
|
"""
|
|
231
230
|
Выгружает аудио.
|
|
232
231
|
|
|
233
232
|
:param file_path: Путь к файлу.
|
|
234
233
|
:type file_path: Path
|
|
235
234
|
:return: ID файла или `None` в случае неудачи.
|
|
236
|
-
:rtype: str | None
|
|
235
|
+
:rtype: tuple[types.Message, str | None]
|
|
237
236
|
"""
|
|
238
237
|
|
|
239
238
|
ChatID = cast(int, self.__ChatID)
|
|
240
|
-
Bot = cast(TeleBot, self.__Bot)
|
|
241
239
|
FileID: str | None = None
|
|
242
240
|
|
|
243
|
-
Message =
|
|
241
|
+
Message = self.__Bot.send_audio(chat_id = ChatID, audio = types.InputFile(file_path))
|
|
244
242
|
if Message.audio: FileID = Message.audio.file_id
|
|
245
243
|
|
|
246
|
-
return FileID
|
|
244
|
+
return Message, FileID
|
|
247
245
|
|
|
248
|
-
def __Upload_Document(self, file_path: Path) -> str | None:
|
|
246
|
+
def __Upload_Document(self, file_path: Path) -> tuple[types.Message, str | None]:
|
|
249
247
|
"""
|
|
250
248
|
Выгружает документ.
|
|
251
249
|
|
|
252
250
|
:param file_path: Путь к файлу.
|
|
253
251
|
:type file_path: Path
|
|
254
252
|
:return: ID файла или `None` в случае неудачи.
|
|
255
|
-
:rtype: str | None
|
|
253
|
+
:rtype: tuple[types.Message, str | None]
|
|
256
254
|
"""
|
|
257
255
|
|
|
258
256
|
ChatID = cast(int, self.__ChatID)
|
|
259
|
-
Bot = cast(TeleBot, self.__Bot)
|
|
260
257
|
FileID: str | None = None
|
|
261
258
|
|
|
262
|
-
Message =
|
|
259
|
+
Message = self.__Bot.send_document(chat_id = ChatID, document = types.InputFile(file_path))
|
|
263
260
|
if Message.document: FileID = Message.document.file_id
|
|
264
261
|
|
|
265
|
-
return FileID
|
|
262
|
+
return Message, FileID
|
|
266
263
|
|
|
267
|
-
def __Upload_Photo(self, file_path: Path) -> str | None:
|
|
264
|
+
def __Upload_Photo(self, file_path: Path) -> tuple[types.Message, str | None]:
|
|
268
265
|
"""
|
|
269
266
|
Выгружает изображение.
|
|
270
267
|
|
|
271
268
|
:param file_path: Путь к файлу.
|
|
272
269
|
:type file_path: Path
|
|
273
270
|
:return: ID файла или `None` в случае неудачи.
|
|
274
|
-
:rtype: str | None
|
|
271
|
+
:rtype: tuple[types.Message, str | None]
|
|
275
272
|
"""
|
|
276
273
|
|
|
277
274
|
ChatID = cast(int, self.__ChatID)
|
|
278
|
-
Bot = cast(TeleBot, self.__Bot)
|
|
279
275
|
FileID: str | None = None
|
|
280
276
|
|
|
281
|
-
Message =
|
|
277
|
+
Message = self.__Bot.send_photo(chat_id = ChatID, photo = types.InputFile(file_path))
|
|
282
278
|
if Message.photo: FileID = Message.photo[-1].file_id
|
|
283
279
|
|
|
284
|
-
return FileID
|
|
280
|
+
return Message, FileID
|
|
285
281
|
|
|
286
|
-
def __Upload_Video(self, file_path: Path) -> str | None:
|
|
282
|
+
def __Upload_Video(self, file_path: Path) -> tuple[types.Message, str | None]:
|
|
287
283
|
"""
|
|
288
284
|
Выгружает видео.
|
|
289
285
|
|
|
290
286
|
:param file_path: Путь к файлу.
|
|
291
287
|
:type file_path: Path
|
|
292
288
|
:return: ID файла или `None` в случае неудачи.
|
|
293
|
-
:rtype: str | None
|
|
289
|
+
:rtype: tuple[types.Message, str | None]
|
|
294
290
|
"""
|
|
295
291
|
|
|
296
292
|
ChatID = cast(int, self.__ChatID)
|
|
297
|
-
Bot = cast(TeleBot, self.__Bot)
|
|
298
293
|
FileID: str | None = None
|
|
299
294
|
|
|
300
|
-
Message =
|
|
295
|
+
Message = self.__Bot.send_video(chat_id = ChatID, video = types.InputFile(file_path))
|
|
301
296
|
if Message.video: FileID = Message.video.file_id
|
|
302
297
|
|
|
303
|
-
return FileID
|
|
298
|
+
return Message, FileID
|
|
304
299
|
|
|
305
300
|
#==========================================================================================#
|
|
306
301
|
# >>>>> ПРИВАТНЫЕ МЕТОДЫ <<<<< #
|
|
@@ -365,11 +360,11 @@ class TeleCache:
|
|
|
365
360
|
FileID: str | None = None
|
|
366
361
|
|
|
367
362
|
match attachment_type:
|
|
368
|
-
case types.InputMediaAnimation: FileID = self.__Upload_Animation(FilePath)
|
|
369
|
-
case types.InputMediaAudio: FileID = self.__Upload_Audio(FilePath)
|
|
370
|
-
case types.InputMediaDocument: FileID = self.__Upload_Document(FilePath)
|
|
371
|
-
case types.InputMediaPhoto: FileID = self.__Upload_Photo(FilePath)
|
|
372
|
-
case types.InputMediaVideo: FileID = self.__Upload_Video(FilePath)
|
|
363
|
+
case types.InputMediaAnimation: Message, FileID = self.__Upload_Animation(FilePath)
|
|
364
|
+
case types.InputMediaAudio: Message, FileID = self.__Upload_Audio(FilePath)
|
|
365
|
+
case types.InputMediaDocument: Message, FileID = self.__Upload_Document(FilePath)
|
|
366
|
+
case types.InputMediaPhoto: Message, FileID = self.__Upload_Photo(FilePath)
|
|
367
|
+
case types.InputMediaVideo: Message, FileID = self.__Upload_Video(FilePath)
|
|
373
368
|
|
|
374
369
|
if not FileID or not Message:
|
|
375
370
|
raise UnableCacheFileError(FilePath)
|
|
@@ -577,7 +572,6 @@ class TeleCache:
|
|
|
577
572
|
:rtype: VirtualCachedFile
|
|
578
573
|
"""
|
|
579
574
|
|
|
580
|
-
self.__Bot = cast(TeleBot, self.__Bot)
|
|
581
575
|
self.__ChatID = cast(int, self.__ChatID)
|
|
582
576
|
|
|
583
577
|
if not attachment_type: attachment_type = types.InputMediaDocument
|
|
@@ -92,18 +92,14 @@ class WebRequestor:
|
|
|
92
92
|
|
|
93
93
|
#---> Переключение HTTP/HTTPS протоколов прокси при неудачном запросе.
|
|
94
94
|
#==========================================================================================#
|
|
95
|
-
if
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
NewResponse = WebResponse(self.__Config)
|
|
105
|
-
self.__RequestsMethods[request_type][self.__Config.lib](NewResponse, url, CurrentProxy, **kwargs)
|
|
106
|
-
if NewResponse.status_code in self.__Config.good_codes: Response = NewResponse
|
|
95
|
+
if not Response.ok and CurrentProxy and self.__Config.switch_proxy_protocol and CurrentProxy.protocol in (Protocols.HTTP, Protocols.HTTPS):
|
|
96
|
+
match CurrentProxy.protocol:
|
|
97
|
+
case Protocols.HTTP: CurrentProxy.set_protocol(Protocols.HTTPS)
|
|
98
|
+
case Protocols.HTTPS: CurrentProxy.set_protocol(Protocols.HTTP)
|
|
99
|
+
|
|
100
|
+
NewResponse = WebResponse(self.__Config)
|
|
101
|
+
self.__RequestsMethods[request_type][self.__Config.lib](NewResponse, url, CurrentProxy, **kwargs)
|
|
102
|
+
if NewResponse.status_code in self.__Config.good_codes: Response = NewResponse
|
|
107
103
|
|
|
108
104
|
except Exception as ExceptionData:
|
|
109
105
|
Response.push_exception(ExceptionData)
|
|
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
|
|
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
|
|
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
|
|
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
|