pyquoks 2.0.3__py3-none-any.whl → 2.1.0__py3-none-any.whl
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/__init__.py +2 -2
- pyquoks/data.py +20 -8
- pyquoks/localhost.py +5 -1
- pyquoks/models.py +62 -31
- pyquoks/test.py +7 -2
- pyquoks/utils.py +5 -1
- {pyquoks-2.0.3.dist-info → pyquoks-2.1.0.dist-info}/METADATA +2 -2
- pyquoks-2.1.0.dist-info/RECORD +10 -0
- pyquoks-2.0.3.dist-info/RECORD +0 -10
- {pyquoks-2.0.3.dist-info → pyquoks-2.1.0.dist-info}/WHEEL +0 -0
- {pyquoks-2.0.3.dist-info → pyquoks-2.1.0.dist-info}/licenses/LICENSE +0 -0
pyquoks/__init__.py
CHANGED
pyquoks/data.py
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import configparser
|
|
4
|
+
import datetime
|
|
5
|
+
import io
|
|
6
|
+
import json
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
import sqlite3
|
|
10
|
+
import sys
|
|
11
|
+
import typing
|
|
12
|
+
|
|
13
|
+
import PIL.Image
|
|
14
|
+
import requests
|
|
15
|
+
|
|
4
16
|
import pyquoks.utils
|
|
5
17
|
|
|
6
18
|
|
|
@@ -45,7 +57,7 @@ class DataProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
45
57
|
try:
|
|
46
58
|
with open(self._PATH + self._FILENAME.format(filename), "rb") as file:
|
|
47
59
|
setattr(self, filename, object_class(json.loads(file.read())))
|
|
48
|
-
except:
|
|
60
|
+
except Exception:
|
|
49
61
|
setattr(self, filename, None)
|
|
50
62
|
|
|
51
63
|
|
|
@@ -114,7 +126,7 @@ class AssetsProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
114
126
|
setattr(self, filename, self._parent.file_image(
|
|
115
127
|
path=self._PATH + self._FILENAME.format(filename),
|
|
116
128
|
))
|
|
117
|
-
except:
|
|
129
|
+
except Exception:
|
|
118
130
|
setattr(self, filename, None)
|
|
119
131
|
|
|
120
132
|
class Network(pyquoks.utils._HasRequiredAttributes):
|
|
@@ -151,7 +163,7 @@ class AssetsProvider(pyquoks.utils._HasRequiredAttributes):
|
|
|
151
163
|
setattr(self, attribute, self._parent.network_image(
|
|
152
164
|
url=url,
|
|
153
165
|
))
|
|
154
|
-
except:
|
|
166
|
+
except Exception:
|
|
155
167
|
setattr(self, attribute, None)
|
|
156
168
|
|
|
157
169
|
_REQUIRED_ATTRIBUTES = {
|
|
@@ -298,7 +310,7 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
298
310
|
for attribute, object_type in self._VALUES.items():
|
|
299
311
|
try:
|
|
300
312
|
setattr(self, attribute, self._config.get(self._SECTION, attribute))
|
|
301
|
-
except:
|
|
313
|
+
except Exception:
|
|
302
314
|
self._config.set(self._SECTION, attribute, object_type.__name__)
|
|
303
315
|
with open(self._parent._PATH, "w", encoding="utf-8") as file:
|
|
304
316
|
self._config.write(file)
|
|
@@ -322,7 +334,7 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
322
334
|
setattr(self, attribute, json.loads(getattr(self, attribute)))
|
|
323
335
|
case _:
|
|
324
336
|
raise ValueError(f"{object_type.__name__} type is not supported!")
|
|
325
|
-
except:
|
|
337
|
+
except Exception:
|
|
326
338
|
setattr(self, attribute, None)
|
|
327
339
|
|
|
328
340
|
raise self._incorrect_content_exception
|
|
@@ -337,7 +349,7 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
|
|
|
337
349
|
return {
|
|
338
350
|
attribute: getattr(self, attribute) for attribute in self._VALUES.keys()
|
|
339
351
|
}
|
|
340
|
-
except:
|
|
352
|
+
except Exception:
|
|
341
353
|
return None
|
|
342
354
|
|
|
343
355
|
def update(self, **kwargs) -> None:
|
pyquoks/localhost.py
CHANGED
pyquoks/models.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
import pyquoks.utils
|
|
3
4
|
|
|
4
5
|
|
|
@@ -39,7 +40,7 @@ class Model:
|
|
|
39
40
|
for attribute, object_class in self._OBJECTS.items():
|
|
40
41
|
try:
|
|
41
42
|
setattr(self, attribute, object_class(self._data.get(attribute)))
|
|
42
|
-
except:
|
|
43
|
+
except Exception:
|
|
43
44
|
setattr(self, attribute, None)
|
|
44
45
|
else:
|
|
45
46
|
self._OBJECTS = None
|
|
@@ -60,7 +61,7 @@ class Container:
|
|
|
60
61
|
Attributes:
|
|
61
62
|
_ATTRIBUTES: Set of parameters that stored in this container
|
|
62
63
|
_OBJECTS: Dictionary with attributes and their models
|
|
63
|
-
_DATA: Dictionary with
|
|
64
|
+
_DATA: Dictionary with attributes and models stored in their lists
|
|
64
65
|
_data: Initial data that was passed into object
|
|
65
66
|
"""
|
|
66
67
|
|
|
@@ -70,38 +71,68 @@ class Container:
|
|
|
70
71
|
|
|
71
72
|
_DATA: dict[str, type] | None
|
|
72
73
|
|
|
73
|
-
_data: dict
|
|
74
|
+
_data: dict
|
|
75
|
+
|
|
76
|
+
def __init__(self, data: dict) -> None:
|
|
77
|
+
self._data = data
|
|
78
|
+
|
|
79
|
+
if hasattr(self, "_ATTRIBUTES"):
|
|
80
|
+
if isinstance(self._ATTRIBUTES, set):
|
|
81
|
+
for attribute in self._ATTRIBUTES:
|
|
82
|
+
setattr(self, attribute, self._data.get(attribute, None))
|
|
83
|
+
else:
|
|
84
|
+
self._ATTRIBUTES = None
|
|
85
|
+
|
|
86
|
+
if hasattr(self, "_OBJECTS"):
|
|
87
|
+
if isinstance(self._OBJECTS, dict):
|
|
88
|
+
for attribute, object_class in self._OBJECTS.items():
|
|
89
|
+
try:
|
|
90
|
+
setattr(self, attribute, object_class(self._data.get(attribute)))
|
|
91
|
+
except Exception:
|
|
92
|
+
setattr(self, attribute, None)
|
|
93
|
+
else:
|
|
94
|
+
self._OBJECTS = None
|
|
95
|
+
|
|
96
|
+
if hasattr(self, "_DATA"):
|
|
97
|
+
if isinstance(self._DATA, dict):
|
|
98
|
+
for attribute, object_class in self._DATA.items():
|
|
99
|
+
try:
|
|
100
|
+
setattr(self, attribute, [object_class(data) for data in self._data.get(attribute)])
|
|
101
|
+
except Exception:
|
|
102
|
+
setattr(self, attribute, None)
|
|
103
|
+
else:
|
|
104
|
+
self._DATA = None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class Listing:
|
|
108
|
+
"""
|
|
109
|
+
Class for storing list of models
|
|
110
|
+
|
|
111
|
+
**Optional attributes**::
|
|
112
|
+
|
|
113
|
+
_DATA = {"scores": ScoreModel}
|
|
114
|
+
|
|
115
|
+
Attributes:
|
|
116
|
+
_DATA: Dictionary with attribute and model stored in list
|
|
117
|
+
_data: Initial data that was passed into object
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
_DATA: dict[str, type] | None
|
|
121
|
+
|
|
122
|
+
_data: list
|
|
74
123
|
|
|
75
|
-
def __init__(self, data:
|
|
124
|
+
def __init__(self, data: list) -> None:
|
|
76
125
|
self._data = data
|
|
77
126
|
|
|
78
|
-
if
|
|
79
|
-
if
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
setattr(self, attribute, self._data
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if isinstance(self._OBJECTS, dict):
|
|
88
|
-
for attribute, object_class in self._OBJECTS.items():
|
|
89
|
-
try:
|
|
90
|
-
setattr(self, attribute, object_class(self._data.get(attribute)))
|
|
91
|
-
except:
|
|
92
|
-
setattr(self, attribute, None)
|
|
93
|
-
else:
|
|
94
|
-
self._OBJECTS = None
|
|
95
|
-
elif isinstance(self._data, list):
|
|
96
|
-
if hasattr(self, "_DATA"):
|
|
97
|
-
if isinstance(self._DATA, dict):
|
|
98
|
-
for attribute, object_class in self._DATA.items():
|
|
99
|
-
try:
|
|
100
|
-
setattr(self, attribute, [object_class(data) for data in self._data])
|
|
101
|
-
except:
|
|
102
|
-
setattr(self, attribute, None)
|
|
103
|
-
else:
|
|
104
|
-
self._DATA = None
|
|
127
|
+
if hasattr(self, "_DATA"):
|
|
128
|
+
if isinstance(self._DATA, dict):
|
|
129
|
+
for attribute, object_class in self._DATA.items():
|
|
130
|
+
try:
|
|
131
|
+
setattr(self, attribute, [object_class(data) for data in self._data])
|
|
132
|
+
except Exception:
|
|
133
|
+
setattr(self, attribute, None)
|
|
134
|
+
else:
|
|
135
|
+
self._DATA = None
|
|
105
136
|
|
|
106
137
|
|
|
107
138
|
class Values(pyquoks.utils._HasRequiredAttributes):
|
pyquoks/test.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import types
|
|
4
|
+
import typing
|
|
5
|
+
import unittest
|
|
6
|
+
|
|
7
|
+
import pyquoks.data
|
|
8
|
+
import pyquoks.utils
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
class TestCase(unittest.TestCase, pyquoks.utils._HasRequiredAttributes):
|
pyquoks/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyquoks
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Пакет PyPI для часто используемых модулей в проектах diquoks
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -26,7 +26,7 @@ Requires-Dist: psutil (==7.1.3)
|
|
|
26
26
|
Requires-Dist: requests (==2.32.5)
|
|
27
27
|
Requires-Dist: urllib3 (==2.5.0)
|
|
28
28
|
Requires-Dist: waitress (==3.0.2)
|
|
29
|
-
Requires-Dist: werkzeug (==3.1.
|
|
29
|
+
Requires-Dist: werkzeug (==3.1.4)
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
32
32
|
# pyquoks
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pyquoks/__init__.py,sha256=axiG3ptbyRzfPKNrEGSGb9ZeQztdwWOq_LNbJhZDHOs,143
|
|
2
|
+
pyquoks/data.py,sha256=WnrgMO04anzi1e5AiVDSL-JxwjDRLIm4UceVp9cv8p0,16389
|
|
3
|
+
pyquoks/localhost.py,sha256=dn9Dwx0wKRIudPxOIql7JgsDomUtf-bOr7SkZozAbqk,1100
|
|
4
|
+
pyquoks/models.py,sha256=XXBWKvGgWvMxSIn6EYoAZ_vx7vct2gyMA7bBO4nwSps,4833
|
|
5
|
+
pyquoks/test.py,sha256=i7smDot_13Kzu1gONhLGVFEkXz6x9MFi-_8DBNnRXd4,3060
|
|
6
|
+
pyquoks/utils.py,sha256=iAYG56cZ3xjBnR3wzeF-B5ELcx7UTkQi8H1x3W4vCvk,1517
|
|
7
|
+
pyquoks-2.1.0.dist-info/licenses/LICENSE,sha256=eEd8UIYxvKUY7vqrV1XTFo70_FQdiW6o1fznseCXRJs,1095
|
|
8
|
+
pyquoks-2.1.0.dist-info/METADATA,sha256=OPFRa6UFDe055Pi8QyQMyE3UiEoVaPWkRdtLFNroIUI,1714
|
|
9
|
+
pyquoks-2.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
10
|
+
pyquoks-2.1.0.dist-info/RECORD,,
|
pyquoks-2.0.3.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
pyquoks/__init__.py,sha256=r70_95sq0zntKp4Jjkk_0hgDMBzUGtCK8EGkkCA6k1c,143
|
|
2
|
-
pyquoks/data.py,sha256=UIGz2SexV1-2mTZikJWyOiOXo7aigF3A_vIkYnH2UZ8,16260
|
|
3
|
-
pyquoks/localhost.py,sha256=-SG-VFoQ7gLksydlDFL3jrHwjNDurHkbXWB1rRxuFaA,1087
|
|
4
|
-
pyquoks/models.py,sha256=pJ165gZnc9eeQnLJhJ3om6nhL3c2UZ9THDu060N3V1w,4154
|
|
5
|
-
pyquoks/test.py,sha256=dkVEpNz2WczGbQThOsQU8A4_IcoMlakvZJ1hwObhjIQ,3035
|
|
6
|
-
pyquoks/utils.py,sha256=DY7qPgl84-Ff2dQQYdLf7w4la6FmQ2pWDw-zHWdj1JE,1499
|
|
7
|
-
pyquoks-2.0.3.dist-info/licenses/LICENSE,sha256=eEd8UIYxvKUY7vqrV1XTFo70_FQdiW6o1fznseCXRJs,1095
|
|
8
|
-
pyquoks-2.0.3.dist-info/METADATA,sha256=0wXiKEuPxQRRF-6WYF-ypwHAPXippSwLY3oYCmARL6Q,1714
|
|
9
|
-
pyquoks-2.0.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
10
|
-
pyquoks-2.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|