python-sdk-remote 0.0.172__py3-none-any.whl → 0.0.174__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.
- python_sdk_remote/__init__.py +4 -1
- python_sdk_remote/item.py +3 -1
- python_sdk_remote/our_object.py +41 -159
- {python_sdk_remote-0.0.172.dist-info → python_sdk_remote-0.0.174.dist-info}/METADATA +2 -1
- {python_sdk_remote-0.0.172.dist-info → python_sdk_remote-0.0.174.dist-info}/RECORD +7 -7
- {python_sdk_remote-0.0.172.dist-info → python_sdk_remote-0.0.174.dist-info}/WHEEL +0 -0
- {python_sdk_remote-0.0.172.dist-info → python_sdk_remote-0.0.174.dist-info}/top_level.txt +0 -0
python_sdk_remote/__init__.py
CHANGED
|
@@ -67,7 +67,10 @@ from .our_objects_local import OurObjectsLocal
|
|
|
67
67
|
|
|
68
68
|
# Existing classes
|
|
69
69
|
from .mini_logger import MiniLogger
|
|
70
|
-
|
|
70
|
+
# OurObject moved to our-object-local. Imported from there rather than from the
|
|
71
|
+
# deprecated .our_object re-export, so that `import python_sdk_remote` does not
|
|
72
|
+
# emit a deprecation warning for itself on every single import.
|
|
73
|
+
from our_object_local.our_object import OurObject
|
|
71
74
|
from .version import PACKAGE_VERSION
|
|
72
75
|
|
|
73
76
|
# Constants
|
python_sdk_remote/item.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
2
|
|
|
3
|
-
from .
|
|
3
|
+
# Straight from the owning package, not through our_object.py: that module is the
|
|
4
|
+
# deprecated path and warns, and this package must not warn about itself.
|
|
5
|
+
from our_object_local.our_object import OurObject
|
|
4
6
|
|
|
5
7
|
ENTITY_NAME = "item"
|
|
6
8
|
|
python_sdk_remote/our_object.py
CHANGED
|
@@ -1,174 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
from abc import ABC # , abstractmethod
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from typing import Any, Optional
|
|
1
|
+
"""Backward-compatibility re-export of `OurObject`, which now lives in `our-object-local`.
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
The class moved to the `our-object-local` package so that anything wanting the
|
|
4
|
+
base business object no longer has to take the whole SDK, and so that
|
|
5
|
+
`our-object-field-local` can sit above `fields-local` without a cycle:
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
our-object-field-local -> fields-local -> python-sdk-remote -> our-object-local
|
|
9
8
|
|
|
9
|
+
`our-object-local` declares no circlez dependencies at all, which is what keeps
|
|
10
|
+
that chain acyclic.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
- String representation
|
|
18
|
-
- Attribute access
|
|
19
|
-
|
|
20
|
-
Usage: Extend this class for all business entities to ensure consistent behavior.
|
|
21
|
-
"""
|
|
22
|
-
class OurObject(ABC):
|
|
23
|
-
|
|
24
|
-
entity_name: Optional[str] = None
|
|
25
|
-
id: Optional[int] = None
|
|
26
|
-
|
|
27
|
-
# Needed by print_our_object_with_id()
|
|
28
|
-
name: Optional[str] = None
|
|
29
|
-
number: Optional[int] = None
|
|
30
|
-
|
|
31
|
-
fields = {
|
|
32
|
-
# Needed by print_our_object_with_id()
|
|
33
|
-
"name",
|
|
34
|
-
"number"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
def __init__(self, entity_name: Optional[str] = None,
|
|
38
|
-
id: Optional[int] = None, **kwargs: Any):
|
|
39
|
-
INIT_METHOD_NAME = '__init__'
|
|
40
|
-
logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
|
|
41
|
-
self.set_entity_name(entity_name)
|
|
42
|
-
self.set_id(id)
|
|
43
|
-
self.kwargs = kwargs
|
|
44
|
-
logger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
|
|
45
|
-
|
|
46
|
-
def __convert_kwargs_to_fields(self, kwargs, fields):
|
|
47
|
-
"""Convert kwargs to object fields based on allowed fields list."""
|
|
48
|
-
for field, value in kwargs.items():
|
|
49
|
-
if field in fields:
|
|
50
|
-
setattr(self, field, value)
|
|
51
|
-
|
|
52
|
-
def __convert_fields_to_kwargs(self, fields, kwargs):
|
|
53
|
-
"""
|
|
54
|
-
Convert fields to kwargs format.
|
|
55
|
-
|
|
56
|
-
Note: This method may be removed in future versions if unused.
|
|
57
|
-
"""
|
|
58
|
-
for field in fields:
|
|
59
|
-
if field in kwargs:
|
|
60
|
-
setattr(self, field, kwargs[field])
|
|
61
|
-
else:
|
|
62
|
-
setattr(self, field, None)
|
|
12
|
+
This module is temporary. It exists only so that
|
|
13
|
+
`from python_sdk_remote.our_object import OurObject` - what every consumer
|
|
14
|
+
writes today - keeps working while they migrate: `Contact` (contact-local),
|
|
15
|
+
`Event` (event-local), `FieldLocal` (fields-local), `CalendarLocal`
|
|
16
|
+
(calendar-local), `Item` (in this package), and both `GenericCRUD.foreach()`
|
|
17
|
+
and `HelperMysqlObject` in database-mysql-local.
|
|
63
18
|
|
|
64
|
-
|
|
65
|
-
self.entity_name = entity_name
|
|
19
|
+
New code should import from the owning package instead:
|
|
66
20
|
|
|
67
|
-
|
|
68
|
-
"""Returns the name of the column that is used as the id of the object"""
|
|
69
|
-
# BEHAVIOUR NOTE: was `self.entity_name + "_id"`, which raised
|
|
70
|
-
# TypeError on the default entity_name of None. Same fix as in
|
|
71
|
-
# our-object-local, so the two copies stay identical.
|
|
72
|
-
id_column_name = str(self.entity_name) + "_id"
|
|
73
|
-
return id_column_name
|
|
21
|
+
from our_object_local.our_object import OurObject
|
|
74
22
|
|
|
75
|
-
|
|
76
|
-
|
|
23
|
+
Reading `OurObject` from here calls `deprecation_warning_function`, so every
|
|
24
|
+
remaining caller shows up in the logs - and therefore in the metrics - with its
|
|
25
|
+
own file name. That is what tells us when this module can be deleted. The
|
|
26
|
+
warning is raised from a module-level `__getattr__` (PEP 562) rather than at
|
|
27
|
+
import time on purpose: at import time the only frame above us is
|
|
28
|
+
`<frozen importlib._bootstrap>`, which names no caller and measures nothing.
|
|
77
29
|
|
|
78
|
-
|
|
79
|
-
|
|
30
|
+
Nothing inside this package reads `OurObject` through this module - `item.py`
|
|
31
|
+
and `__init__.py` import it straight from `our_object_local` - so every warning
|
|
32
|
+
counted here comes from a real consumer.
|
|
80
33
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# raise NotImplementedError(
|
|
86
|
-
# "Subclasses must implement the 'get_name' method.")
|
|
87
|
-
return None
|
|
88
|
-
|
|
89
|
-
def get(self, attr_name: str) -> Any:
|
|
90
|
-
"""Returns the value of the attribute with the given name"""
|
|
91
|
-
GET_METHOD_NAME = 'get'
|
|
92
|
-
logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
93
|
-
# BEHAVIOUR NOTE: the getattr default of None was already there, but
|
|
94
|
-
# .get() was then called on it unconditionally, so any instance built
|
|
95
|
-
# without __init__ - from_json does exactly that - raised
|
|
96
|
-
# AttributeError. Same guard as in our-object-local.
|
|
97
|
-
arguments = getattr(self, 'kwargs', None)
|
|
98
|
-
value = arguments.get(attr_name, None) if arguments else None
|
|
99
|
-
logger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
100
|
-
return value
|
|
101
|
-
|
|
102
|
-
def get_all_arguments(self):
|
|
103
|
-
"""Returns all the arguments passed to the constructor as a dictionary"""
|
|
104
|
-
get_all_arguments_result = getattr(self, 'kwargs', None)
|
|
105
|
-
return get_all_arguments_result
|
|
106
|
-
|
|
107
|
-
def to_json(self) -> str:
|
|
108
|
-
"""This is backwards compatible with the previous implementation"""
|
|
109
|
-
to_json_result = self.to_json_str()
|
|
110
|
-
return to_json_result
|
|
111
|
-
|
|
112
|
-
def to_json_dict(self) -> str:
|
|
113
|
-
"""Returns a json string representation of this object"""
|
|
114
|
-
json_str = self.to_json_str()
|
|
115
|
-
json_dict = json.loads(json_str)
|
|
116
|
-
|
|
117
|
-
return json_dict
|
|
118
|
-
|
|
119
|
-
def to_json_str(self) -> str:
|
|
120
|
-
"""Returns a json string representation of this object"""
|
|
121
|
-
to_json_str_result = json.dumps(self.__dict__, default=self._serialize)
|
|
122
|
-
return to_json_str_result
|
|
123
|
-
|
|
124
|
-
@staticmethod
|
|
125
|
-
def _serialize(obj):
|
|
126
|
-
"""Custom serialization function for unsupported types. Used by json.dumps"""
|
|
127
|
-
if isinstance(obj, datetime):
|
|
128
|
-
return obj.isoformat() # Converts datetime to ISO 8601 string
|
|
129
|
-
raise TypeError(f"Type {type(obj)} not serializable")
|
|
130
|
-
|
|
131
|
-
def from_json(self, json_string: str) -> 'OurObject':
|
|
132
|
-
"""Returns an instance of the class from a json string"""
|
|
133
|
-
FROM_JSON_METHOD_NAME = 'from_json'
|
|
134
|
-
logger.start(FROM_JSON_METHOD_NAME,
|
|
135
|
-
object={'json_string': json_string})
|
|
136
|
-
self.__dict__ = json.loads(json_string)
|
|
137
|
-
logger.end(FROM_JSON_METHOD_NAME,
|
|
138
|
-
object={'json_dict': self.__dict__})
|
|
139
|
-
return self
|
|
34
|
+
Not to be confused with `OurObjectsLocal` (plural) in `our_objects_local.py`,
|
|
35
|
+
which is an unrelated `GenericCRUD` collection layer that stays in this package.
|
|
36
|
+
"""
|
|
37
|
+
from typing import TYPE_CHECKING, Any
|
|
140
38
|
|
|
141
|
-
|
|
142
|
-
"""Checks if two objects are equal"""
|
|
143
|
-
if not isinstance(other, OurObject):
|
|
144
|
-
return False
|
|
145
|
-
eq_result = self.__dict__ == other.__dict__
|
|
146
|
-
return eq_result
|
|
39
|
+
from .utilities import deprecation_warning_function
|
|
147
40
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
ne_result = not self.__eq__(other)
|
|
151
|
-
return ne_result
|
|
41
|
+
if TYPE_CHECKING: # so type checkers still resolve OurObject to the real class
|
|
42
|
+
from our_object_local.our_object import OurObject
|
|
152
43
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return str_result
|
|
44
|
+
OLD_OUR_OBJECT_IMPORT_PATH = 'python_sdk_remote.our_object.OurObject'
|
|
45
|
+
NEW_OUR_OBJECT_IMPORT_PATH = 'our_object_local.our_object.OurObject'
|
|
156
46
|
|
|
157
|
-
|
|
158
|
-
"""String representation for debugging."""
|
|
159
|
-
# Ensure both entity_name and __dict__ are not None for proper representation
|
|
160
|
-
entity_name = self.entity_name or "OurObject"
|
|
161
|
-
dict_str = str(self.__dict__) if self.__dict__ else "{}"
|
|
162
|
-
repr_result = f"{entity_name}: {dict_str}"
|
|
163
|
-
return repr_result
|
|
47
|
+
__all__ = ['OurObject']
|
|
164
48
|
|
|
165
|
-
def to_dict(self):
|
|
166
|
-
return self.__dict__
|
|
167
49
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
50
|
+
def __getattr__(name: str) -> Any:
|
|
51
|
+
if name == 'OurObject':
|
|
52
|
+
deprecation_warning_function(old_name=OLD_OUR_OBJECT_IMPORT_PATH,
|
|
53
|
+
new_name=NEW_OUR_OBJECT_IMPORT_PATH)
|
|
54
|
+
from our_object_local.our_object import OurObject as our_object_class
|
|
55
|
+
return our_object_class
|
|
56
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sdk-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.174
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -12,6 +12,7 @@ Requires-Dist: requests
|
|
|
12
12
|
Requires-Dist: python-dotenv
|
|
13
13
|
Requires-Dist: url-remote
|
|
14
14
|
Requires-Dist: pyjwt
|
|
15
|
+
Requires-Dist: our-object-local
|
|
15
16
|
Dynamic: author
|
|
16
17
|
Dynamic: author-email
|
|
17
18
|
Dynamic: classifier
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
python_sdk_remote/__init__.py,sha256=
|
|
1
|
+
python_sdk_remote/__init__.py,sha256=wBfMpAOPwxDMD4wdG74B5OboGVmC_fKGlEid4p8iAeY,3790
|
|
2
2
|
python_sdk_remote/constants.py,sha256=UBJta5-UdA1Y-owTesMB4TMht-ZvHApYwXAG8EtL6uE,1372
|
|
3
3
|
python_sdk_remote/constants_src_mini_logger_and_logger.py,sha256=EB9-UIX-YRfLcFCT1VianrngcoTso397gF07a3WM3zk,437
|
|
4
4
|
python_sdk_remote/datetime_range.py,sha256=5dCA6vSTnqp6pnd5exEVsmbeWpaee-oxfG0cE21eW_k,4376
|
|
@@ -6,10 +6,10 @@ python_sdk_remote/exceptions.py,sha256=N4eiN-ijGW3hBOp6AnMy28NH_Ekbtu57b6Zcqzofk
|
|
|
6
6
|
python_sdk_remote/generic_crud.py,sha256=jzmR27kr8Pnf4Gk90SKoxbM5ufLsOr2ofekRtcHw248,9907
|
|
7
7
|
python_sdk_remote/http_response.py,sha256=T659q_iPt8SkT8k-T4ZfRy9VSh0uvHyluecqwZnhRqI,12888
|
|
8
8
|
python_sdk_remote/is_test_data.py,sha256=ZVu7ylFMV2FO0w0Huxqo5AXyZZ8GwbqJn3bWMRVR5ZE,110
|
|
9
|
-
python_sdk_remote/item.py,sha256=
|
|
9
|
+
python_sdk_remote/item.py,sha256=SH7kKyoJ5i6f_FmoEahmeITznuzbgThaT1IAyHdM8mk,494
|
|
10
10
|
python_sdk_remote/mini_logger.py,sha256=0bWAT0XeB2B-_rTf9Ql6uewZsSgGasQ5rp3aRmsp1xE,6585
|
|
11
11
|
python_sdk_remote/our_obfuscation.py,sha256=YrQksRpJ_AwEio4xHq_TE8BQDXNGUbCQ-5E0OkcXYeM,10717
|
|
12
|
-
python_sdk_remote/our_object.py,sha256=
|
|
12
|
+
python_sdk_remote/our_object.py,sha256=wQsoe0fL-HQHd8vkiMsjlCaCJopkz5GsYgdVcsjEkKQ,2610
|
|
13
13
|
python_sdk_remote/our_objects.py,sha256=CUcuh5bYaO2JiVKu_hMsPqiWOuURMge0NBnnS_UpWZY,254
|
|
14
14
|
python_sdk_remote/our_objects_local.py,sha256=vfBGZ25uFVzCMPahbrQ9OTwIDyMh2w8FApsCkgvqFcY,7655
|
|
15
15
|
python_sdk_remote/our_objects_remote.py,sha256=fdgZwA8DaNA5G3thdUTCj7TRrO6xpqxvR5MJPZ19g1Y,140
|
|
@@ -20,7 +20,7 @@ python_sdk_remote/utilities.py,sha256=1nlrE6FXVIdQDtLmF7IR935D6HMKoXIdp5vXRu6t_s
|
|
|
20
20
|
python_sdk_remote/valid_json_versions.py,sha256=zVtvhsEDKkfK3o8crdcP6YWjLnzh-OykWGPT7vghb6k,147
|
|
21
21
|
python_sdk_remote/validate_environment.py,sha256=VQKta418TmJwkUGXp0Rorhy65YANoNVgg86BIYPf2Wc,2321
|
|
22
22
|
python_sdk_remote/version.py,sha256=nJV1jCPXMEluCrvcEBWwM8BS6DzFTv7pULfqjGXs3uA,421
|
|
23
|
-
python_sdk_remote-0.0.
|
|
24
|
-
python_sdk_remote-0.0.
|
|
25
|
-
python_sdk_remote-0.0.
|
|
26
|
-
python_sdk_remote-0.0.
|
|
23
|
+
python_sdk_remote-0.0.174.dist-info/METADATA,sha256=bHC3i-azJySipirsSHiBI4Av8QqCySgbMtjm2u4I9I4,761
|
|
24
|
+
python_sdk_remote-0.0.174.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
25
|
+
python_sdk_remote-0.0.174.dist-info/top_level.txt,sha256=JTpEq_svPlI5hTlPq30Ne-NkR-u5464gjVDP2U74PvE,18
|
|
26
|
+
python_sdk_remote-0.0.174.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|