internal 0.1.10__py3-none-any.whl → 0.1.12__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.

Potentially problematic release.


This version of internal might be problematic. Click here for more details.

internal/model/operate.py CHANGED
@@ -1,9 +1,31 @@
1
1
  from typing import Optional
2
2
 
3
3
  from .base_model import InternalBaseModel
4
+ from deepdiff import DeepDiff
5
+ from beanie import Document
4
6
 
5
7
 
6
- class Operate(InternalBaseModel):
8
+ class Operate(Document):
7
9
  add: Optional[dict] = None
8
10
  remove: Optional[dict] = None
9
11
  change: Optional[dict] = None
12
+
13
+ @classmethod
14
+ async def compare_diff(cls, original: dict, compare: dict):
15
+ original = cls.remove_ignore_field(original)
16
+ compare = cls.remove_ignore_field(compare)
17
+
18
+ diff_result = DeepDiff(original, compare, ignore_order=True)
19
+ if not diff_result:
20
+ return None
21
+
22
+ operate = Operate(
23
+ add=diff_result.get("iterable_items_added", None),
24
+ remove=diff_result.get("iterable_items_removed", None),
25
+ change=diff_result.get("values_changed", None)
26
+ )
27
+ return operate
28
+
29
+ @classmethod
30
+ async def remove_ignore_field(cls, model_dict: dict):
31
+ return {k: v for k, v in model_dict.items() if k not in ['create_time', 'update_time']}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 0.1.10
3
+ Version: 0.1.12
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.11
10
10
  Classifier: Programming Language :: Python :: 3.12
11
11
  Requires-Dist: arrow (>=1.3.0,<2.0.0)
12
12
  Requires-Dist: beanie (>=1.24.0,<2.0.0)
13
+ Requires-Dist: deepdiff (>=6.7.1,<7.0.0)
13
14
  Requires-Dist: fastapi (>=0.109.0,<0.110.0)
14
15
  Requires-Dist: httpx (>=0.26.0,<0.27.0)
15
16
  Requires-Dist: pydantic-settings (>=2.1.0,<3.0.0)
@@ -14,8 +14,8 @@ internal/http/requests.py,sha256=BZPlrfNbxO2-fOiIQxioX9qwiYlBsfwMF2tJN-AnOcE,502
14
14
  internal/http/responses.py,sha256=rYXj9FfFWn9yG8RrBsf_YaOLnzGPP6lgQ2bIVqLckr4,962
15
15
  internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  internal/model/base_model.py,sha256=lr2vNKFIJFX--wJutMMD6iSuIg2P07V0-sicxtPWyow,256
17
- internal/model/operate.py,sha256=aZTESVTrXjdv26QaDXYzGBIkhnr7dPTKVlp1dcOMOCc,206
17
+ internal/model/operate.py,sha256=xPD5lXsPNBKC7FuiTSUYA7SU8PWzCnJw7AmfhllLieg,986
18
18
  internal/utils.py,sha256=tDas83c_tDsWHBDMa-m3f3HXYbmel8kif8TWdLBr6LU,1440
19
- internal-0.1.10.dist-info/METADATA,sha256=47hCEjB3Vq73B6W-2xIw0NJFMGz_EqAV05j0mXH5knI,581
20
- internal-0.1.10.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
21
- internal-0.1.10.dist-info/RECORD,,
19
+ internal-0.1.12.dist-info/METADATA,sha256=8ASriuX9uxg2zRZUbfwdppgPOGZzO_6zk6dC7-_vAsI,622
20
+ internal-0.1.12.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
21
+ internal-0.1.12.dist-info/RECORD,,