pyquoks 2.2.0__py3-none-any.whl → 2.2.1.1__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/data.py CHANGED
@@ -312,12 +312,18 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
312
312
  """
313
313
 
314
314
  for attribute, value in kwargs.items():
315
+
315
316
  if attribute not in self._VALUES.keys():
316
317
  raise AttributeError(f"{attribute} is not specified!")
317
318
 
318
- if type(value) is not self._VALUES.get(attribute):
319
+ object_type = self._VALUES.get(attribute)
320
+
321
+ if not isinstance(
322
+ value,
323
+ typing.get_origin(object_type) if typing.get_origin(object_type) else object_type,
324
+ ):
319
325
  raise AttributeError(
320
- f"{attribute} has incorrect type! (must be {self._VALUES.get(attribute).__name__})",
326
+ f"{attribute} has incorrect type! (must be {object_type.__name__})",
321
327
  )
322
328
 
323
329
  setattr(self, attribute, value)
@@ -395,38 +401,37 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
395
401
  """
396
402
 
397
403
  for attribute, value in kwargs.items():
404
+ value: pydantic.BaseModel | list[pydantic.BaseModel]
405
+
398
406
  if attribute not in self._OBJECTS.keys():
399
407
  raise AttributeError(f"{attribute} is not specified!")
400
408
 
401
- object_class = self._OBJECTS.get(attribute)
409
+ object_type = self._OBJECTS.get(attribute)
402
410
 
403
- try:
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)
408
- except Exception:
411
+ if not isinstance(
412
+ value,
413
+ typing.get_origin(object_type) if typing.get_origin(object_type) else object_type,
414
+ ):
409
415
  raise AttributeError(
410
- f"{attribute} cannot be converted to {object_class.__name__}!",
411
- )
412
- else:
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))
417
-
418
- os.makedirs(
419
- name=self._PATH,
420
- exist_ok=True,
416
+ f"{attribute} has incorrect type! (must be {object_type.__name__})",
421
417
  )
422
418
 
423
- with open(self._PATH + self._FILENAME.format(attribute), "w", encoding="utf-8") as file:
424
- json.dump(
425
- value,
426
- fp=file,
427
- ensure_ascii=False,
428
- indent=2,
429
- )
419
+ setattr(self, attribute, value)
420
+
421
+ os.makedirs(
422
+ name=self._PATH,
423
+ exist_ok=True,
424
+ )
425
+
426
+ with open(self._PATH + self._FILENAME.format(attribute), "w", encoding="utf-8") as file:
427
+ json.dump(
428
+ [model.model_dump() for model in value] if typing.get_origin(
429
+ object_type,
430
+ ) == list else value.model_dump(),
431
+ fp=file,
432
+ ensure_ascii=False,
433
+ indent=2,
434
+ )
430
435
 
431
436
 
432
437
  class DatabaseManager(pyquoks.utils._HasRequiredAttributes):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyquoks
3
- Version: 2.2.0
3
+ Version: 2.2.1.1
4
4
  Summary: Пакет PyPI для часто используемых модулей в проектах diquoks
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -28,7 +28,7 @@ Requires-Dist: pydantic-core (==2.41.5)
28
28
  Requires-Dist: requests (==2.32.5)
29
29
  Requires-Dist: typing-extensions (==4.15.0)
30
30
  Requires-Dist: typing-inspection (==0.4.2)
31
- Requires-Dist: urllib3 (==2.6.1)
31
+ Requires-Dist: urllib3 (==2.6.2)
32
32
  Requires-Dist: waitress (==3.0.2)
33
33
  Requires-Dist: werkzeug (==3.1.4)
34
34
  Description-Content-Type: text/markdown
@@ -0,0 +1,9 @@
1
+ pyquoks/__init__.py,sha256=u62PPaulBuYAxCYvLzsPkJb9hezXHCg6ZONHmnCJf-I,120
2
+ pyquoks/data.py,sha256=xvydnHUAILEK9kqI5UYY8KS36Hf3ORK9ZwgwAt8K318,18132
3
+ pyquoks/localhost.py,sha256=HPixbz33l4ZkLrk__kbb4mekPjJKA78-Lpi3AjCWvgs,1062
4
+ pyquoks/test.py,sha256=Hx3cLng0uDMDVMx-NveLOPlgpX51A00aVELa0sbR5D0,3379
5
+ pyquoks/utils.py,sha256=6uC5QUtPtVt4G5iiP2jog0t-4IUshUQPshJwmsEwmqg,1475
6
+ pyquoks-2.2.1.1.dist-info/licenses/LICENSE,sha256=eEd8UIYxvKUY7vqrV1XTFo70_FQdiW6o1fznseCXRJs,1095
7
+ pyquoks-2.2.1.1.dist-info/METADATA,sha256=PjmiP5rZQ1XNEs7_wUS9KTvB6cEVVUQF_S_vGLzoOjY,1868
8
+ pyquoks-2.2.1.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
+ pyquoks-2.2.1.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pyquoks/__init__.py,sha256=u62PPaulBuYAxCYvLzsPkJb9hezXHCg6ZONHmnCJf-I,120
2
- pyquoks/data.py,sha256=-5O-BQC02HIAX_lvNm8BizxkKaXZt1v5qmLCg2-7fdg,18095
3
- pyquoks/localhost.py,sha256=HPixbz33l4ZkLrk__kbb4mekPjJKA78-Lpi3AjCWvgs,1062
4
- pyquoks/test.py,sha256=Hx3cLng0uDMDVMx-NveLOPlgpX51A00aVELa0sbR5D0,3379
5
- pyquoks/utils.py,sha256=6uC5QUtPtVt4G5iiP2jog0t-4IUshUQPshJwmsEwmqg,1475
6
- pyquoks-2.2.0.dist-info/licenses/LICENSE,sha256=eEd8UIYxvKUY7vqrV1XTFo70_FQdiW6o1fznseCXRJs,1095
7
- pyquoks-2.2.0.dist-info/METADATA,sha256=_anNhJlV75weo2K3vFTzRPDTif1QkZYv7na3aHlvC5w,1866
8
- pyquoks-2.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
- pyquoks-2.2.0.dist-info/RECORD,,