pyquoks 2.2.0__py3-none-any.whl → 2.2.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
@@ -315,9 +315,11 @@ class ConfigManager(pyquoks.utils._HasRequiredAttributes):
315
315
  if attribute not in self._VALUES.keys():
316
316
  raise AttributeError(f"{attribute} is not specified!")
317
317
 
318
- if type(value) is not self._VALUES.get(attribute):
318
+ object_type = self._VALUES.get(attribute)
319
+
320
+ if type(value) is not object_type:
319
321
  raise AttributeError(
320
- f"{attribute} has incorrect type! (must be {self._VALUES.get(attribute).__name__})",
322
+ f"{attribute} has incorrect type! (must be {object_type.__name__})",
321
323
  )
322
324
 
323
325
  setattr(self, attribute, value)
@@ -398,35 +400,29 @@ class DataManager(pyquoks.utils._HasRequiredAttributes):
398
400
  if attribute not in self._OBJECTS.keys():
399
401
  raise AttributeError(f"{attribute} is not specified!")
400
402
 
401
- object_class = self._OBJECTS.get(attribute)
403
+ object_type = self._OBJECTS.get(attribute)
402
404
 
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:
405
+ if type(value) is not object_type:
409
406
  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,
407
+ f"{attribute} has incorrect type! (must be {object_type.__name__})",
421
408
  )
422
409
 
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
- )
410
+ setattr(self, attribute, value)
411
+
412
+ os.makedirs(
413
+ name=self._PATH,
414
+ exist_ok=True,
415
+ )
416
+
417
+ with open(self._PATH + self._FILENAME.format(attribute), "w", encoding="utf-8") as file:
418
+ json.dump(
419
+ [model.model_dump() for model in value] if typing.get_origin(
420
+ object_type,
421
+ ) == list else value.model_dump(),
422
+ fp=file,
423
+ ensure_ascii=False,
424
+ indent=2,
425
+ )
430
426
 
431
427
 
432
428
  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
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
@@ -1,9 +1,9 @@
1
1
  pyquoks/__init__.py,sha256=u62PPaulBuYAxCYvLzsPkJb9hezXHCg6ZONHmnCJf-I,120
2
- pyquoks/data.py,sha256=-5O-BQC02HIAX_lvNm8BizxkKaXZt1v5qmLCg2-7fdg,18095
2
+ pyquoks/data.py,sha256=p9ieX1Uh-ke24WtdOTGhg9jm4-zG55zFwXpvXHX5fwk,17786
3
3
  pyquoks/localhost.py,sha256=HPixbz33l4ZkLrk__kbb4mekPjJKA78-Lpi3AjCWvgs,1062
4
4
  pyquoks/test.py,sha256=Hx3cLng0uDMDVMx-NveLOPlgpX51A00aVELa0sbR5D0,3379
5
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,,
6
+ pyquoks-2.2.1.dist-info/licenses/LICENSE,sha256=eEd8UIYxvKUY7vqrV1XTFo70_FQdiW6o1fznseCXRJs,1095
7
+ pyquoks-2.2.1.dist-info/METADATA,sha256=zI1GGBVSsdrRTwSA0HhuLKrQ2qNKwtSIBq1aCNuUz6s,1866
8
+ pyquoks-2.2.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
+ pyquoks-2.2.1.dist-info/RECORD,,