pyquoks 2.1.2__tar.gz → 2.2.0__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.1.2 → pyquoks-2.2.0}/PKG-INFO +8 -4
- {pyquoks-2.1.2 → pyquoks-2.2.0}/pyproject.toml +8 -3
- pyquoks-2.2.0/src/pyquoks/__init__.py +8 -0
- {pyquoks-2.1.2 → pyquoks-2.2.0}/src/pyquoks/data.py +44 -34
- {pyquoks-2.1.2 → pyquoks-2.2.0}/src/pyquoks/localhost.py +0 -2
- {pyquoks-2.1.2 → pyquoks-2.2.0}/src/pyquoks/test.py +0 -2
- {pyquoks-2.1.2 → pyquoks-2.2.0}/src/pyquoks/utils.py +0 -2
- pyquoks-2.1.2/src/pyquoks/__init__.py +0 -9
- pyquoks-2.1.2/src/pyquoks/models.py +0 -166
- {pyquoks-2.1.2 → pyquoks-2.2.0}/LICENSE +0 -0
- {pyquoks-2.1.2 → pyquoks-2.2.0}/README.md +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyquoks
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Пакет PyPI для часто используемых модулей в проектах diquoks
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Author: Denis Titovets
|
|
8
8
|
Author-email: den232titovets@yandex.ru
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: annotated-types (==0.7.0)
|
|
14
14
|
Requires-Dist: blinker (==1.9.0)
|
|
15
15
|
Requires-Dist: certifi (==2025.11.12)
|
|
16
16
|
Requires-Dist: charset-normalizer (==3.4.4)
|
|
@@ -23,8 +23,12 @@ Requires-Dist: jinja2 (==3.1.6)
|
|
|
23
23
|
Requires-Dist: markupsafe (==3.0.3)
|
|
24
24
|
Requires-Dist: pillow (==12.0.0)
|
|
25
25
|
Requires-Dist: psutil (==7.1.3)
|
|
26
|
+
Requires-Dist: pydantic (==2.12.5)
|
|
27
|
+
Requires-Dist: pydantic-core (==2.41.5)
|
|
26
28
|
Requires-Dist: requests (==2.32.5)
|
|
27
|
-
Requires-Dist:
|
|
29
|
+
Requires-Dist: typing-extensions (==4.15.0)
|
|
30
|
+
Requires-Dist: typing-inspection (==0.4.2)
|
|
31
|
+
Requires-Dist: urllib3 (==2.6.1)
|
|
28
32
|
Requires-Dist: waitress (==3.0.2)
|
|
29
33
|
Requires-Dist: werkzeug (==3.1.4)
|
|
30
34
|
Description-Content-Type: text/markdown
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyquoks"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.2.0"
|
|
4
4
|
description = "Пакет PyPI для часто используемых модулей в проектах diquoks"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Denis Titovets <den232titovets@yandex.ru>" }
|
|
7
7
|
]
|
|
8
8
|
license = { text = "MIT" }
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.14"
|
|
11
11
|
dependencies = [
|
|
12
|
+
"annotated-types (==0.7.0)",
|
|
12
13
|
"blinker (==1.9.0)",
|
|
13
14
|
"certifi (==2025.11.12)",
|
|
14
15
|
"charset-normalizer (==3.4.4)",
|
|
@@ -21,8 +22,12 @@ dependencies = [
|
|
|
21
22
|
"markupsafe (==3.0.3)",
|
|
22
23
|
"pillow (==12.0.0)",
|
|
23
24
|
"psutil (==7.1.3)",
|
|
25
|
+
"pydantic (==2.12.5)",
|
|
26
|
+
"pydantic-core (==2.41.5)",
|
|
24
27
|
"requests (==2.32.5)",
|
|
25
|
-
"
|
|
28
|
+
"typing-inspection (==0.4.2)",
|
|
29
|
+
"typing-extensions (==4.15.0)",
|
|
30
|
+
"urllib3 (==2.6.1)",
|
|
26
31
|
"waitress (==3.0.2)",
|
|
27
32
|
"werkzeug (==3.1.4)"
|
|
28
33
|
]
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
import configparser
|
|
4
2
|
import datetime
|
|
5
3
|
import io
|
|
@@ -11,6 +9,7 @@ import sys
|
|
|
11
9
|
import typing
|
|
12
10
|
|
|
13
11
|
import PIL.Image
|
|
12
|
+
import pydantic
|
|
14
13
|
import requests
|
|
15
14
|
|
|
16
15
|
import pyquoks.utils
|
|
@@ -78,13 +77,13 @@ class AssetsProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
78
77
|
|
|
79
78
|
self._PATH = self._parent._PATH + self._PATH
|
|
80
79
|
|
|
81
|
-
for
|
|
80
|
+
for attribute in self._ATTRIBUTES:
|
|
82
81
|
try:
|
|
83
|
-
setattr(self,
|
|
84
|
-
path=self._PATH + self._FILENAME.format(
|
|
82
|
+
setattr(self, attribute, self._parent.file_image(
|
|
83
|
+
path=self._PATH + self._FILENAME.format(attribute),
|
|
85
84
|
))
|
|
86
85
|
except Exception:
|
|
87
|
-
setattr(self,
|
|
86
|
+
setattr(self, attribute, None)
|
|
88
87
|
|
|
89
88
|
class Network(pyquoks.utils._HasRequiredAttributes):
|
|
90
89
|
"""
|
|
@@ -135,8 +134,8 @@ class AssetsProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
135
134
|
def __init__(self) -> None:
|
|
136
135
|
self._check_attributes()
|
|
137
136
|
|
|
138
|
-
for attribute,
|
|
139
|
-
setattr(self, attribute,
|
|
137
|
+
for attribute, child_class in self._OBJECTS.items():
|
|
138
|
+
setattr(self, attribute, child_class(self))
|
|
140
139
|
|
|
141
140
|
@staticmethod
|
|
142
141
|
def file_image(path: str) -> PIL.Image.Image:
|
|
@@ -192,8 +191,8 @@ class StringsProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
192
191
|
def __init__(self) -> None:
|
|
193
192
|
self._check_attributes()
|
|
194
193
|
|
|
195
|
-
for attribute,
|
|
196
|
-
setattr(self, attribute,
|
|
194
|
+
for attribute, child_class in self._OBJECTS.items():
|
|
195
|
+
setattr(self, attribute, child_class(self))
|
|
197
196
|
|
|
198
197
|
|
|
199
198
|
# endregion
|
|
@@ -272,20 +271,20 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
272
271
|
|
|
273
272
|
for attribute, object_type in self._VALUES.items():
|
|
274
273
|
try:
|
|
275
|
-
match object_type
|
|
276
|
-
case
|
|
277
|
-
pass
|
|
278
|
-
case int.__name__:
|
|
279
|
-
setattr(self, attribute, int(getattr(self, attribute)))
|
|
280
|
-
case float.__name__:
|
|
281
|
-
setattr(self, attribute, float(getattr(self, attribute)))
|
|
282
|
-
case bool.__name__:
|
|
274
|
+
match object_type():
|
|
275
|
+
case bool():
|
|
283
276
|
if getattr(self, attribute) not in [str(True), str(False)]:
|
|
284
277
|
setattr(self, attribute, None)
|
|
285
278
|
raise self._incorrect_content_exception
|
|
286
279
|
else:
|
|
287
280
|
setattr(self, attribute, getattr(self, attribute) == str(True))
|
|
288
|
-
case
|
|
281
|
+
case int():
|
|
282
|
+
setattr(self, attribute, int(getattr(self, attribute)))
|
|
283
|
+
case float():
|
|
284
|
+
setattr(self, attribute, float(getattr(self, attribute)))
|
|
285
|
+
case str():
|
|
286
|
+
pass
|
|
287
|
+
case dict() | list():
|
|
289
288
|
setattr(self, attribute, json.loads(getattr(self, attribute)))
|
|
290
289
|
case _:
|
|
291
290
|
raise ValueError(f"{object_type.__name__} type is not supported!")
|
|
@@ -339,8 +338,8 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
339
338
|
def __init__(self) -> None:
|
|
340
339
|
self._check_attributes()
|
|
341
340
|
|
|
342
|
-
for attribute,
|
|
343
|
-
setattr(self, attribute,
|
|
341
|
+
for attribute, child_class in self._OBJECTS.items():
|
|
342
|
+
setattr(self, attribute, child_class(self))
|
|
344
343
|
|
|
345
344
|
|
|
346
345
|
class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
@@ -349,7 +348,7 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
349
348
|
|
|
350
349
|
**Required attributes**::
|
|
351
350
|
|
|
352
|
-
_OBJECTS = {"users":
|
|
351
|
+
_OBJECTS = {"users": list[UserModel]}
|
|
353
352
|
|
|
354
353
|
# Predefined:
|
|
355
354
|
|
|
@@ -358,7 +357,7 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
358
357
|
_FILENAME = "{0}.json"
|
|
359
358
|
|
|
360
359
|
Attributes:
|
|
361
|
-
_OBJECTS: Dictionary with filenames and
|
|
360
|
+
_OBJECTS: Dictionary with filenames and types of models
|
|
362
361
|
_PATH: Path to the directory with JSON-like files
|
|
363
362
|
_FILENAME: Filename of JSON-like files
|
|
364
363
|
"""
|
|
@@ -369,7 +368,7 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
369
368
|
"_FILENAME",
|
|
370
369
|
}
|
|
371
370
|
|
|
372
|
-
_OBJECTS: dict[str, type]
|
|
371
|
+
_OBJECTS: dict[str, type[pydantic.BaseModel] | list[type[pydantic.BaseModel]]]
|
|
373
372
|
|
|
374
373
|
_PATH: str = pyquoks.utils.get_path("data/")
|
|
375
374
|
|
|
@@ -378,12 +377,17 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
378
377
|
def __init__(self) -> None:
|
|
379
378
|
self._check_attributes()
|
|
380
379
|
|
|
381
|
-
for
|
|
380
|
+
for attribute, object_type in self._OBJECTS.items():
|
|
382
381
|
try:
|
|
383
|
-
with open(self._PATH + self._FILENAME.format(
|
|
384
|
-
|
|
382
|
+
with open(self._PATH + self._FILENAME.format(attribute), "rb") as file:
|
|
383
|
+
data = json.loads(file.read())
|
|
384
|
+
|
|
385
|
+
if typing.get_origin(object_type) == list:
|
|
386
|
+
setattr(self, attribute, [typing.get_args(object_type)[0](**model) for model in data])
|
|
387
|
+
else:
|
|
388
|
+
setattr(self, attribute, object_type(**data))
|
|
385
389
|
except Exception:
|
|
386
|
-
setattr(self,
|
|
390
|
+
setattr(self, attribute, None)
|
|
387
391
|
|
|
388
392
|
def update(self, **kwargs) -> None:
|
|
389
393
|
"""
|
|
@@ -397,13 +401,19 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
397
401
|
object_class = self._OBJECTS.get(attribute)
|
|
398
402
|
|
|
399
403
|
try:
|
|
400
|
-
object_class
|
|
404
|
+
if typing.get_origin(object_class) == list:
|
|
405
|
+
[typing.get_args(object_class)[0](**model) for model in value]
|
|
406
|
+
else:
|
|
407
|
+
object_class(**value)
|
|
401
408
|
except Exception:
|
|
402
409
|
raise AttributeError(
|
|
403
410
|
f"{attribute} cannot be converted to {object_class.__name__}!",
|
|
404
411
|
)
|
|
405
412
|
else:
|
|
406
|
-
|
|
413
|
+
if typing.get_origin(object_class) == list:
|
|
414
|
+
setattr(self, attribute, [typing.get_args(object_class)[0](**model) for model in value])
|
|
415
|
+
else:
|
|
416
|
+
setattr(self, attribute, object_class(**value))
|
|
407
417
|
|
|
408
418
|
os.makedirs(
|
|
409
419
|
name=self._PATH,
|
|
@@ -512,16 +522,16 @@ class DatabaseManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
512
522
|
exist_ok=True,
|
|
513
523
|
)
|
|
514
524
|
|
|
515
|
-
for attribute,
|
|
516
|
-
setattr(self, attribute,
|
|
525
|
+
for attribute, child_class in self._OBJECTS.items():
|
|
526
|
+
setattr(self, attribute, child_class(self))
|
|
517
527
|
|
|
518
528
|
def close_all(self) -> None:
|
|
519
529
|
"""
|
|
520
530
|
Closes all database connections
|
|
521
531
|
"""
|
|
522
532
|
|
|
523
|
-
for
|
|
524
|
-
getattr(self,
|
|
533
|
+
for attribute in self._OBJECTS.keys():
|
|
534
|
+
getattr(self, attribute).close()
|
|
525
535
|
|
|
526
536
|
|
|
527
537
|
# endregion
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
|
|
5
|
-
import pyquoks.utils
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class _HasInitialData:
|
|
9
|
-
"""
|
|
10
|
-
Assistive class for providing initial data
|
|
11
|
-
|
|
12
|
-
Attributes:
|
|
13
|
-
_data: Initial data that was passed into object
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
_data: typing.Any
|
|
17
|
-
|
|
18
|
-
def __init__(self, data: typing.Any) -> None:
|
|
19
|
-
self._data = data
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class Model(_HasInitialData):
|
|
23
|
-
"""
|
|
24
|
-
Class for storing parameters and models
|
|
25
|
-
|
|
26
|
-
**Optional attributes**::
|
|
27
|
-
|
|
28
|
-
_ATTRIBUTES = {"beatmap_id", "score_id"}
|
|
29
|
-
|
|
30
|
-
_OBJECTS = {"beatmap": BeatmapModel}
|
|
31
|
-
|
|
32
|
-
Attributes:
|
|
33
|
-
_ATTRIBUTES: Set of parameters that stored in this model
|
|
34
|
-
_OBJECTS: Dictionary with attributes and their models
|
|
35
|
-
_data: Initial data that was passed into object
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
_ATTRIBUTES: set[str] | None
|
|
39
|
-
|
|
40
|
-
_OBJECTS: dict[str, type] | None
|
|
41
|
-
|
|
42
|
-
_data: dict
|
|
43
|
-
|
|
44
|
-
def __init__(self, data: dict) -> None:
|
|
45
|
-
super().__init__(data)
|
|
46
|
-
|
|
47
|
-
if hasattr(self, "_ATTRIBUTES"):
|
|
48
|
-
if isinstance(self._ATTRIBUTES, set):
|
|
49
|
-
for attribute in self._ATTRIBUTES:
|
|
50
|
-
setattr(self, attribute, self._data.get(attribute, None))
|
|
51
|
-
else:
|
|
52
|
-
self._ATTRIBUTES = None
|
|
53
|
-
|
|
54
|
-
if hasattr(self, "_OBJECTS"):
|
|
55
|
-
if isinstance(self._OBJECTS, dict):
|
|
56
|
-
for attribute, object_class in self._OBJECTS.items():
|
|
57
|
-
try:
|
|
58
|
-
setattr(self, attribute, object_class(self._data.get(attribute)))
|
|
59
|
-
except Exception:
|
|
60
|
-
setattr(self, attribute, None)
|
|
61
|
-
else:
|
|
62
|
-
self._OBJECTS = None
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class Container(Model, _HasInitialData):
|
|
66
|
-
"""
|
|
67
|
-
Class for storing lists of models and another parameters
|
|
68
|
-
|
|
69
|
-
**Optional attributes**::
|
|
70
|
-
|
|
71
|
-
_ATTRIBUTES = {"beatmap_id", "score_id"}
|
|
72
|
-
|
|
73
|
-
_OBJECTS = {"beatmap": BeatmapModel}
|
|
74
|
-
|
|
75
|
-
_DATA = {"scores": ScoreModel}
|
|
76
|
-
|
|
77
|
-
Attributes:
|
|
78
|
-
_ATTRIBUTES: Set of parameters that stored in this container
|
|
79
|
-
_OBJECTS: Dictionary with attributes and their models
|
|
80
|
-
_DATA: Dictionary with attributes and models stored in their lists
|
|
81
|
-
_data: Initial data that was passed into object
|
|
82
|
-
"""
|
|
83
|
-
|
|
84
|
-
_ATTRIBUTES: set[str] | None
|
|
85
|
-
|
|
86
|
-
_OBJECTS: dict[str, type] | None
|
|
87
|
-
|
|
88
|
-
_DATA: dict[str, type] | None
|
|
89
|
-
|
|
90
|
-
_data: dict
|
|
91
|
-
|
|
92
|
-
def __init__(self, data: dict) -> None:
|
|
93
|
-
super().__init__(data)
|
|
94
|
-
|
|
95
|
-
if hasattr(self, "_DATA"):
|
|
96
|
-
if isinstance(self._DATA, dict):
|
|
97
|
-
for attribute, object_class in self._DATA.items():
|
|
98
|
-
try:
|
|
99
|
-
setattr(self, attribute, [object_class(data) for data in self._data.get(attribute)])
|
|
100
|
-
except Exception:
|
|
101
|
-
setattr(self, attribute, None)
|
|
102
|
-
else:
|
|
103
|
-
self._DATA = None
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
class Listing(_HasInitialData):
|
|
107
|
-
"""
|
|
108
|
-
Class for storing list of models
|
|
109
|
-
|
|
110
|
-
**Optional attributes**::
|
|
111
|
-
|
|
112
|
-
_DATA = {"scores": ScoreModel}
|
|
113
|
-
|
|
114
|
-
Attributes:
|
|
115
|
-
_DATA: Dictionary with attribute and model stored in list
|
|
116
|
-
_data: Initial data that was passed into object
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
_DATA: dict[str, type] | None
|
|
120
|
-
|
|
121
|
-
_data: list
|
|
122
|
-
|
|
123
|
-
def __init__(self, data: list) -> None:
|
|
124
|
-
super().__init__(data)
|
|
125
|
-
|
|
126
|
-
if hasattr(self, "_DATA"):
|
|
127
|
-
if isinstance(self._DATA, dict):
|
|
128
|
-
for attribute, object_class in self._DATA.items():
|
|
129
|
-
try:
|
|
130
|
-
setattr(self, attribute, [object_class(data) for data in self._data])
|
|
131
|
-
except Exception:
|
|
132
|
-
setattr(self, attribute, None)
|
|
133
|
-
else:
|
|
134
|
-
self._DATA = None
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class Values(pyquoks.utils._HasRequiredAttributes):
|
|
138
|
-
"""
|
|
139
|
-
Class for storing various parameters and values
|
|
140
|
-
|
|
141
|
-
**Required attributes**::
|
|
142
|
-
|
|
143
|
-
_ATTRIBUTES = {"settings", "path"}
|
|
144
|
-
|
|
145
|
-
Attributes:
|
|
146
|
-
_ATTRIBUTES: Attributes that can be stored in this class
|
|
147
|
-
"""
|
|
148
|
-
|
|
149
|
-
_REQUIRED_ATTRIBUTES = {
|
|
150
|
-
"_ATTRIBUTES",
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
_ATTRIBUTES: set[str]
|
|
154
|
-
|
|
155
|
-
def __init__(self, **kwargs) -> None:
|
|
156
|
-
self._check_attributes()
|
|
157
|
-
|
|
158
|
-
for attribute in self._ATTRIBUTES:
|
|
159
|
-
setattr(self, attribute, kwargs.get(attribute, getattr(self, attribute, None)))
|
|
160
|
-
|
|
161
|
-
def update(self, **kwargs) -> None:
|
|
162
|
-
"""
|
|
163
|
-
Updates provided attributes in object
|
|
164
|
-
"""
|
|
165
|
-
|
|
166
|
-
self.__init__(**kwargs)
|
|
File without changes
|
|
File without changes
|