internal 1.0.29__tar.gz → 1.0.30__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.

Potentially problematic release.


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

Files changed (33) hide show
  1. {internal-1.0.29 → internal-1.0.30}/PKG-INFO +1 -1
  2. {internal-1.0.29 → internal-1.0.30}/pyproject.toml +1 -1
  3. internal-1.0.30/src/internal/interface/base_interface.py +44 -0
  4. internal-1.0.29/src/internal/interface/base_interface.py +0 -13
  5. {internal-1.0.29 → internal-1.0.30}/README.md +0 -0
  6. {internal-1.0.29 → internal-1.0.30}/src/internal/__init__.py +0 -0
  7. {internal-1.0.29 → internal-1.0.30}/src/internal/base_config.py +0 -0
  8. {internal-1.0.29 → internal-1.0.30}/src/internal/base_factory.py +0 -0
  9. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/__init__.py +0 -0
  10. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/contact_type.py +0 -0
  11. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/description_type.py +0 -0
  12. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/event_trigger_type.py +0 -0
  13. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/operator_type.py +0 -0
  14. {internal-1.0.29 → internal-1.0.30}/src/internal/common_enum/order_type.py +0 -0
  15. {internal-1.0.29 → internal-1.0.30}/src/internal/const.py +0 -0
  16. {internal-1.0.29 → internal-1.0.30}/src/internal/database.py +0 -0
  17. {internal-1.0.29 → internal-1.0.30}/src/internal/exception/__init__.py +0 -0
  18. {internal-1.0.29 → internal-1.0.30}/src/internal/exception/base_exception.py +0 -0
  19. {internal-1.0.29 → internal-1.0.30}/src/internal/exception/internal_exception.py +0 -0
  20. {internal-1.0.29 → internal-1.0.30}/src/internal/ext/__init__.py +0 -0
  21. {internal-1.0.29 → internal-1.0.30}/src/internal/ext/amazon/__init__.py +0 -0
  22. {internal-1.0.29 → internal-1.0.30}/src/internal/ext/amazon/aws/__init__.py +0 -0
  23. {internal-1.0.29 → internal-1.0.30}/src/internal/ext/amazon/aws/const.py +0 -0
  24. {internal-1.0.29 → internal-1.0.30}/src/internal/http/__init__.py +0 -0
  25. {internal-1.0.29 → internal-1.0.30}/src/internal/http/requests.py +0 -0
  26. {internal-1.0.29 → internal-1.0.30}/src/internal/http/responses.py +0 -0
  27. {internal-1.0.29 → internal-1.0.30}/src/internal/interface/__init__.py +0 -0
  28. {internal-1.0.29 → internal-1.0.30}/src/internal/middleware/__init__.py +0 -0
  29. {internal-1.0.29 → internal-1.0.30}/src/internal/middleware/log_request.py +0 -0
  30. {internal-1.0.29 → internal-1.0.30}/src/internal/model/__init__.py +0 -0
  31. {internal-1.0.29 → internal-1.0.30}/src/internal/model/base_model.py +0 -0
  32. {internal-1.0.29 → internal-1.0.30}/src/internal/model/operate.py +0 -0
  33. {internal-1.0.29 → internal-1.0.30}/src/internal/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 1.0.29
3
+ Version: 1.0.30
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "internal"
3
- version = "1.0.29"
3
+ version = "1.0.30"
4
4
  description = ""
5
5
  authors = ["Ray <ray@cruisys.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,44 @@
1
+ from dataclasses import dataclass, field, asdict, fields
2
+ from typing import Optional
3
+
4
+
5
+ @dataclass
6
+ class InternalBaseInterface:
7
+ def __post_init__(self):
8
+ # 初始化 __explicitly_set_fields__ 集合
9
+ self.__explicitly_set_fields__ = set()
10
+
11
+ for f in fields(self):
12
+ value = getattr(self, f.name)
13
+ if f.name in self.__explicitly_set_fields__ or value is not f.default:
14
+ self.__explicitly_set_fields__.add(f.name)
15
+
16
+ def __init__(self, **kwargs):
17
+ # 初始化 __explicitly_set_fields__ 集合
18
+ self.__explicitly_set_fields__ = set()
19
+
20
+ for f in fields(self):
21
+ if f.name in kwargs:
22
+ value = kwargs[f.name]
23
+ setattr(self, f.name, value)
24
+ self.__explicitly_set_fields__.add(f.name)
25
+ else:
26
+ setattr(self, f.name, f.default)
27
+
28
+ def to_dict(self, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False):
29
+ # 將 dataclass 轉換為字典
30
+ data = asdict(self)
31
+
32
+ if exclude_unset:
33
+ # 過濾掉那些未被明確設置的欄位
34
+ data = {k: v for k, v in data.items() if k in self.__explicitly_set_fields__ or v is not None}
35
+
36
+ if exclude_defaults:
37
+ # 過濾掉那些設置為預設值的欄位
38
+ data = {k: v for k, v in data.items() if v != self.__dataclass_fields__[k].default}
39
+
40
+ if exclude_none:
41
+ # 過濾掉那些值為 None 的欄位
42
+ data = {k: v for k, v in data.items() if v is not None}
43
+
44
+ return data
@@ -1,13 +0,0 @@
1
- from dataclasses import dataclass, asdict, fields
2
- from typing import Optional
3
-
4
-
5
- @dataclass
6
- class InternalBaseInterface:
7
- def __init__(self, **kwargs):
8
- valid_fields = {f.name: kwargs.get(f.name) for f in fields(self)}
9
- for name, value in valid_fields.items():
10
- setattr(self, name, value)
11
-
12
- def to_dict(self):
13
- return {k: v for k, v in asdict(self).items() if v is not None}
File without changes