pyquoks 2.7.0__tar.gz → 2.7.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.
- {pyquoks-2.7.0 → pyquoks-2.7.2}/PKG-INFO +2 -7
- {pyquoks-2.7.0 → pyquoks-2.7.2}/README.md +1 -6
- {pyquoks-2.7.0 → pyquoks-2.7.2}/pyproject.toml +3 -3
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/managers/config.py +16 -11
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/managers/database.py +8 -4
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/providers/assets.py +4 -2
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/services/logger.py +24 -24
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/utils.py +9 -8
- {pyquoks-2.7.0 → pyquoks-2.7.2}/LICENSE +0 -0
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/__init__.py +0 -0
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/managers/__init__.py +0 -0
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/providers/__init__.py +0 -0
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/providers/environment.py +0 -0
- {pyquoks-2.7.0 → pyquoks-2.7.2}/src/pyquoks/services/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyquoks
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.2
|
|
4
4
|
Summary: Пакет PyPI для часто используемых модулей в проектах diquoks
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -25,7 +25,6 @@ Description-Content-Type: text/markdown
|
|
|
25
25
|
|
|
26
26
|
- [Контакты](#контакты)
|
|
27
27
|
- [Связь с разработчиком](#связь-с-разработчиком)
|
|
28
|
-
- [Прочие ссылки](#прочие-ссылки)
|
|
29
28
|
|
|
30
29
|
---
|
|
31
30
|
|
|
@@ -34,9 +33,5 @@ Description-Content-Type: text/markdown
|
|
|
34
33
|
#### Связь с разработчиком
|
|
35
34
|
|
|
36
35
|
- [Telegram для связи](https://t.me/diquoks)
|
|
37
|
-
- [Почта для связи](mailto:
|
|
38
|
-
|
|
39
|
-
#### Прочие ссылки
|
|
40
|
-
|
|
41
|
-
- [Telegram-канал с новостями](https://t.me/diquoks_channel)
|
|
36
|
+
- [Почта для связи](mailto:den232titovets@yandex.ru)
|
|
42
37
|
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
- [Контакты](#контакты)
|
|
10
10
|
- [Связь с разработчиком](#связь-с-разработчиком)
|
|
11
|
-
- [Прочие ссылки](#прочие-ссылки)
|
|
12
11
|
|
|
13
12
|
---
|
|
14
13
|
|
|
@@ -17,8 +16,4 @@
|
|
|
17
16
|
#### Связь с разработчиком
|
|
18
17
|
|
|
19
18
|
- [Telegram для связи](https://t.me/diquoks)
|
|
20
|
-
- [Почта для связи](mailto:
|
|
21
|
-
|
|
22
|
-
#### Прочие ссылки
|
|
23
|
-
|
|
24
|
-
- [Telegram-канал с новостями](https://t.me/diquoks_channel)
|
|
19
|
+
- [Почта для связи](mailto:den232titovets@yandex.ru)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyquoks"
|
|
3
|
-
version = "2.7.
|
|
3
|
+
version = "2.7.2"
|
|
4
4
|
dependencies = [
|
|
5
5
|
"pillow (>=12.2.0,<13.0.0)",
|
|
6
6
|
"psutil (>=7.2.2,<8.0.0)",
|
|
7
7
|
"pydantic (>=2.13.4,<3.0.0)",
|
|
8
|
-
"requests (>=2.34.2,<3.0.0)"
|
|
8
|
+
"requests (>=2.34.2,<3.0.0)",
|
|
9
9
|
]
|
|
10
10
|
requires-python = ">=3.14.0,<4.0.0"
|
|
11
11
|
authors = [
|
|
@@ -20,7 +20,7 @@ license-files = ["LICENSE"]
|
|
|
20
20
|
dev = [
|
|
21
21
|
"poetry (>=2.4.1,<3.0.0)",
|
|
22
22
|
"pytest (>=9.0.3,<10.0.0)",
|
|
23
|
-
"twine (>=6.2.0,<7.0.0)"
|
|
23
|
+
"twine (>=6.2.0,<7.0.0)",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
[tool.pytest]
|
|
@@ -29,8 +29,10 @@ class ConfigManager(utils._HasRequiredAttributes):
|
|
|
29
29
|
self._check_attributes()
|
|
30
30
|
|
|
31
31
|
for attribute, object_type in self.__class__.__annotations__.items():
|
|
32
|
-
if issubclass(object_type, Config):
|
|
33
|
-
|
|
32
|
+
if not issubclass(object_type, Config):
|
|
33
|
+
continue
|
|
34
|
+
|
|
35
|
+
setattr(self, attribute, object_type(self))
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
class Config(utils._HasRequiredAttributes):
|
|
@@ -84,8 +86,8 @@ class Config(utils._HasRequiredAttributes):
|
|
|
84
86
|
if getattr(self, attribute) not in [str(True), str(False)]:
|
|
85
87
|
setattr(self, attribute, None)
|
|
86
88
|
raise self._incorrect_content_exception
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
|
|
90
|
+
setattr(self, attribute, getattr(self, attribute) == str(True))
|
|
89
91
|
case int():
|
|
90
92
|
setattr(self, attribute, int(getattr(self, attribute)))
|
|
91
93
|
case float():
|
|
@@ -134,13 +136,16 @@ class Config(utils._HasRequiredAttributes):
|
|
|
134
136
|
|
|
135
137
|
setattr(self, attribute, value)
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
try:
|
|
140
|
+
match object_type():
|
|
141
|
+
case bool() | int() | float() | str():
|
|
142
|
+
self._config.set(self._SECTION, attribute, str(value))
|
|
143
|
+
case dict() | list():
|
|
144
|
+
self._config.set(self._SECTION, attribute, json.dumps(value))
|
|
145
|
+
case _:
|
|
146
|
+
raise ValueError()
|
|
147
|
+
except:
|
|
148
|
+
raise ValueError(f"{object_type.__name__} type is not supported!")
|
|
144
149
|
|
|
145
150
|
with open(self._parent._PATH, "w", encoding="utf-8") as file:
|
|
146
151
|
self._config.write(file)
|
|
@@ -33,8 +33,10 @@ class DatabaseManager(utils._HasRequiredAttributes):
|
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
for attribute, object_type in self.__class__.__annotations__.items():
|
|
36
|
-
if issubclass(object_type, Database):
|
|
37
|
-
|
|
36
|
+
if not issubclass(object_type, Database):
|
|
37
|
+
continue
|
|
38
|
+
|
|
39
|
+
setattr(self, attribute, object_type(self))
|
|
38
40
|
|
|
39
41
|
def close_all(self) -> None:
|
|
40
42
|
"""
|
|
@@ -42,8 +44,10 @@ class DatabaseManager(utils._HasRequiredAttributes):
|
|
|
42
44
|
"""
|
|
43
45
|
|
|
44
46
|
for attribute, object_type in self.__class__.__annotations__.items():
|
|
45
|
-
if issubclass(object_type, Database):
|
|
46
|
-
|
|
47
|
+
if not issubclass(object_type, Database):
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
getattr(self, attribute).close()
|
|
47
51
|
|
|
48
52
|
|
|
49
53
|
class Database(sqlite3.Connection, utils._HasRequiredAttributes):
|
|
@@ -30,8 +30,10 @@ class AssetsProvider(utils._HasRequiredAttributes):
|
|
|
30
30
|
self._check_attributes()
|
|
31
31
|
|
|
32
32
|
for attribute, object_type in self.__class__.__annotations__.items():
|
|
33
|
-
if issubclass(object_type, Directory | Network):
|
|
34
|
-
|
|
33
|
+
if not issubclass(object_type, Directory | Network):
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
setattr(self, attribute, object_type(self))
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
class Directory(utils._HasRequiredAttributes):
|
|
@@ -36,28 +36,28 @@ class LoggerService(logging.Logger):
|
|
|
36
36
|
)
|
|
37
37
|
self.addHandler(self.stream_handler)
|
|
38
38
|
|
|
39
|
-
if file_handling:
|
|
40
|
-
os.makedirs(
|
|
41
|
-
name=path,
|
|
42
|
-
exist_ok=True
|
|
43
|
-
)
|
|
44
|
-
self._LOG_PATH = path + f"{int(datetime.datetime.now().timestamp())}.{filename}.log"
|
|
45
|
-
|
|
46
|
-
# noinspection PyTypeChecker
|
|
47
|
-
self.file_handler = logging.FileHandler(
|
|
48
|
-
filename=self._LOG_PATH,
|
|
49
|
-
encoding="utf-8",
|
|
50
|
-
)
|
|
51
|
-
self.file_handler.setFormatter(
|
|
52
|
-
logging.Formatter(
|
|
53
|
-
fmt="$levelname $asctime - $message",
|
|
54
|
-
datefmt="%d-%m-%y %H:%M:%S",
|
|
55
|
-
style="$",
|
|
56
|
-
),
|
|
57
|
-
)
|
|
58
|
-
self.addHandler(self.file_handler)
|
|
59
|
-
else:
|
|
39
|
+
if not file_handling:
|
|
60
40
|
self._LOG_PATH = None
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
os.makedirs(
|
|
44
|
+
name=path,
|
|
45
|
+
exist_ok=True
|
|
46
|
+
)
|
|
47
|
+
self._LOG_PATH: str = path + f"{int(datetime.datetime.now().timestamp())}.{filename}.log"
|
|
48
|
+
|
|
49
|
+
self.file_handler = logging.FileHandler(
|
|
50
|
+
filename=self._LOG_PATH,
|
|
51
|
+
encoding="utf-8",
|
|
52
|
+
)
|
|
53
|
+
self.file_handler.setFormatter(
|
|
54
|
+
logging.Formatter(
|
|
55
|
+
fmt="$levelname $asctime - $message",
|
|
56
|
+
datefmt="%d-%m-%y %H:%M:%S",
|
|
57
|
+
style="$",
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
self.addHandler(self.file_handler)
|
|
61
61
|
|
|
62
62
|
@property
|
|
63
63
|
def file(self) -> typing.IO | None:
|
|
@@ -65,10 +65,10 @@ class LoggerService(logging.Logger):
|
|
|
65
65
|
:return: Opened file-like object of current logs
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
|
-
if self._LOG_PATH:
|
|
68
|
+
if self._LOG_PATH is not None:
|
|
69
69
|
return open(self._LOG_PATH, "rb")
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
|
|
71
|
+
return None
|
|
72
72
|
|
|
73
73
|
def log_exception(self, exception: Exception, raise_again: bool = False) -> None:
|
|
74
74
|
"""
|
|
@@ -56,10 +56,7 @@ def get_process_created_datetime(pid: int | None = None) -> datetime.datetime:
|
|
|
56
56
|
:return: Datetime when the process was created
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
pid = os.getpid()
|
|
61
|
-
|
|
62
|
-
process = psutil.Process(pid)
|
|
59
|
+
process = psutil.Process(pid or os.getpid())
|
|
63
60
|
|
|
64
61
|
return datetime.datetime.fromtimestamp(
|
|
65
62
|
timestamp=process.create_time(),
|
|
@@ -81,7 +78,11 @@ class _HasRequiredAttributes:
|
|
|
81
78
|
_REQUIRED_ATTRIBUTES: set[str]
|
|
82
79
|
|
|
83
80
|
def _check_attributes(self) -> None:
|
|
84
|
-
if hasattr(self, "_REQUIRED_ATTRIBUTES"):
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
if not hasattr(self, "_REQUIRED_ATTRIBUTES"):
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
for attribute in self._REQUIRED_ATTRIBUTES:
|
|
85
|
+
if hasattr(self, attribute):
|
|
86
|
+
continue
|
|
87
|
+
|
|
88
|
+
raise AttributeError(f"The required class attribute is not set! ({attribute})")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|