everysk-lib 1.10.4__cp312-cp312-win_amd64.whl → 1.11.0__cp312-cp312-win_amd64.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.
- everysk/core/_tests/mapping/__init__.py +9 -0
- everysk/core/_tests/mapping/base.py +306 -0
- everysk/core/_tests/mapping/fields.py +1154 -0
- everysk/core/datetime/datetime.py +1 -1
- everysk/core/http.py +6 -6
- everysk/core/mapping/__init__.py +29 -0
- everysk/core/mapping/base.py +214 -0
- everysk/core/mapping/fields.py +1133 -0
- everysk/core/mapping/metaclass.py +101 -0
- everysk/core/object.py +132 -124
- everysk/core/tests.py +19 -0
- everysk/sdk/engines/expression.cp312-win_amd64.pyd +0 -0
- everysk/sdk/engines/helpers.cp312-win_amd64.pyd +0 -0
- everysk/sql/connection.py +24 -0
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/METADATA +1 -1
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/RECORD +20 -13
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/.gitignore +0 -0
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/WHEEL +0 -0
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/licenses/LICENSE.txt +0 -0
- {everysk_lib-1.10.4.dist-info → everysk_lib-1.11.0.dist-info}/top_level.txt +0 -0
|
@@ -332,7 +332,7 @@ class DateTime(DateMixin, datetime): # pylint: disable=inherit-non-class
|
|
|
332
332
|
if force_time == 'MIDDAY':
|
|
333
333
|
hour, minute, second, microsecond = 12, 0, 0, 0
|
|
334
334
|
elif force_time == 'NOW':
|
|
335
|
-
dt_now =
|
|
335
|
+
dt_now = self.now()
|
|
336
336
|
hour, minute, second, microsecond = dt_now.hour, dt_now.minute, dt_now.second, dt_now.microsecond
|
|
337
337
|
elif force_time == 'FIRST_MINUTE':
|
|
338
338
|
hour, minute, second, microsecond = 0, 0, 0, 0
|
everysk/core/http.py
CHANGED
|
@@ -384,12 +384,12 @@ class HttpGETConnection(HttpConnection):
|
|
|
384
384
|
dict: A dictionary containing the URL, headers, parameters, and timeout for the request.
|
|
385
385
|
If a user is specified, the dictionary will also include authentication credentials.
|
|
386
386
|
"""
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
'
|
|
392
|
-
}
|
|
387
|
+
headers = self._get_headers()
|
|
388
|
+
|
|
389
|
+
# If the user not provided custom 'Content-Type' headers via self.headers, remove the default Content-Type header for GET requests # noqa: E501
|
|
390
|
+
if self.headers is None or 'Content-Type' not in self.headers:
|
|
391
|
+
del headers['Content-Type'] # GET requests do not need Content-Type if no custom headers are set
|
|
392
|
+
params = {'url': self.get_url(), 'headers': headers, 'params': self.get_params(), 'timeout': self.get_timeout()}
|
|
393
393
|
if self.user:
|
|
394
394
|
params['auth'] = (self.user, self.password)
|
|
395
395
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2025 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
# ruff: noqa: F401
|
|
11
|
+
from everysk.core.mapping.base import BaseMapping
|
|
12
|
+
from everysk.core.mapping.fields import BaseMappingField as BaseField
|
|
13
|
+
from everysk.core.mapping.fields import (
|
|
14
|
+
BoolField,
|
|
15
|
+
ChoiceField,
|
|
16
|
+
DateField,
|
|
17
|
+
DateTimeField,
|
|
18
|
+
DictField,
|
|
19
|
+
EmailField,
|
|
20
|
+
FloatField,
|
|
21
|
+
IntField,
|
|
22
|
+
IteratorField,
|
|
23
|
+
ListField,
|
|
24
|
+
RegexField,
|
|
25
|
+
SetField,
|
|
26
|
+
StrField,
|
|
27
|
+
TupleField,
|
|
28
|
+
URLField,
|
|
29
|
+
)
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2025 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from typing import Any, TypeVar
|
|
11
|
+
|
|
12
|
+
from everysk.core.mapping.metaclass import BaseMappingMetaClass
|
|
13
|
+
|
|
14
|
+
FT = TypeVar('FT')
|
|
15
|
+
MT = TypeVar('MT', bound='BaseMapping')
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BaseMapping(dict, metaclass=BaseMappingMetaClass):
|
|
19
|
+
## Internal attributes
|
|
20
|
+
__attributes__: set[str] = None
|
|
21
|
+
# To track deleted keys and raise AttributeError on access
|
|
22
|
+
__deleted_keys__: set[str] = None
|
|
23
|
+
# Used to not create certain keys in the instance dict
|
|
24
|
+
__invalid_keys__: frozenset[str] = None
|
|
25
|
+
# Used to enable/disable field validation on set
|
|
26
|
+
__validate_fields__: bool = False
|
|
27
|
+
|
|
28
|
+
## Internal methods
|
|
29
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
30
|
+
# We always need to initialize the deleted attribute in the instance
|
|
31
|
+
self.__deleted_keys__ = set()
|
|
32
|
+
|
|
33
|
+
# We need to set all attributes defined in the class and the
|
|
34
|
+
# ones passed as kwargs in the instance so they appear in the
|
|
35
|
+
# dict representation of the instance if they are valid attributes
|
|
36
|
+
keys = self.__class__.__attributes__ | kwargs.keys()
|
|
37
|
+
for key in keys:
|
|
38
|
+
# Don't use the getattr as the second argument because
|
|
39
|
+
# it will be executed even if the key is in kwargs
|
|
40
|
+
value = kwargs.get(key, Undefined)
|
|
41
|
+
if value is Undefined:
|
|
42
|
+
value = getattr(self.__class__, key)
|
|
43
|
+
|
|
44
|
+
# We only set attributes that are defined in the class
|
|
45
|
+
if key in self.__attributes__:
|
|
46
|
+
setattr(self, key, value)
|
|
47
|
+
else:
|
|
48
|
+
self[key] = value
|
|
49
|
+
|
|
50
|
+
def __delitem__(self, key: str) -> None:
|
|
51
|
+
"""
|
|
52
|
+
Delete the item from the instance dict.
|
|
53
|
+
Updates the deleted keys set to track removed keys.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
key (str): The key to delete.
|
|
57
|
+
"""
|
|
58
|
+
self.__deleted_keys__.add(key)
|
|
59
|
+
return super().__delitem__(key)
|
|
60
|
+
|
|
61
|
+
def __getattr__(self, name: str) -> Any:
|
|
62
|
+
"""
|
|
63
|
+
Get the attribute from the instance dict.
|
|
64
|
+
When an attribute is not found in the instance, this method is called.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
name (str): The name of the attribute to get.
|
|
68
|
+
|
|
69
|
+
Raises:
|
|
70
|
+
AttributeError: If the attribute is not found in the instance.
|
|
71
|
+
"""
|
|
72
|
+
if name in self:
|
|
73
|
+
return self[name]
|
|
74
|
+
|
|
75
|
+
msg = f"'{self.__class__.__name__}' object has no attribute '{name}'."
|
|
76
|
+
raise AttributeError(msg)
|
|
77
|
+
|
|
78
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
79
|
+
"""
|
|
80
|
+
Set the attribute on the instance.
|
|
81
|
+
Only attributes defined in the class are set as attributes the rest go to the dict
|
|
82
|
+
and will be accessible via key access or via __getattr__.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
name (str): The name of the attribute to set.
|
|
86
|
+
value (Any): The value to set for the attribute.
|
|
87
|
+
"""
|
|
88
|
+
# We only set attributes in the object that are already defined
|
|
89
|
+
if hasattr(self, name):
|
|
90
|
+
super().__setattr__(name, value)
|
|
91
|
+
else:
|
|
92
|
+
# Otherwise, everything goes to the dict
|
|
93
|
+
self[name] = value
|
|
94
|
+
|
|
95
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
96
|
+
"""
|
|
97
|
+
Set the value for the given key in the instance dict.
|
|
98
|
+
Updates the changed set to track modified keys.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
key (str): The key to set the value for.
|
|
102
|
+
value (Any): The value to set for the key.
|
|
103
|
+
"""
|
|
104
|
+
if self.__validate_fields__:
|
|
105
|
+
cls = type(self)
|
|
106
|
+
field = cls.__dict__.get(key)
|
|
107
|
+
if field and hasattr(field, 'validate'):
|
|
108
|
+
field.validate(value)
|
|
109
|
+
|
|
110
|
+
super().__setitem__(key, value)
|
|
111
|
+
|
|
112
|
+
## Private methods
|
|
113
|
+
@classmethod
|
|
114
|
+
def _generate_attributes(cls) -> None:
|
|
115
|
+
"""
|
|
116
|
+
Generate the set of attributes for the class by collecting attributes
|
|
117
|
+
from the class and its base classes up to BaseMapping (inclusive).
|
|
118
|
+
"""
|
|
119
|
+
for base in cls.mro()[:-2]:
|
|
120
|
+
keys = getattr(base, '__attributes__', set())
|
|
121
|
+
if keys:
|
|
122
|
+
cls.__attributes__.update(keys)
|
|
123
|
+
# If the base has the attributes, we don't need to get the others
|
|
124
|
+
# because they were already collected in the previous bases
|
|
125
|
+
break
|
|
126
|
+
|
|
127
|
+
# If we don't have the attributes in the base we make it from the annotations
|
|
128
|
+
keys = {key for key in base.__annotations__ if not key.startswith('__')}
|
|
129
|
+
cls.__attributes__.update(keys)
|
|
130
|
+
|
|
131
|
+
def _is_valid_key(self, key: str) -> bool:
|
|
132
|
+
"""
|
|
133
|
+
Check if the given key is valid to be used.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
key (str): The key to check.
|
|
137
|
+
"""
|
|
138
|
+
if self.__invalid_keys__:
|
|
139
|
+
return key not in self.__invalid_keys__
|
|
140
|
+
|
|
141
|
+
return True
|
|
142
|
+
|
|
143
|
+
def _to_dict_excluded_keys(self) -> set[str]:
|
|
144
|
+
"""
|
|
145
|
+
Returns a set of keys to be excluded when converting the object to a dictionary.
|
|
146
|
+
This method can be overridden in subclasses to specify custom keys to exclude.
|
|
147
|
+
"""
|
|
148
|
+
return set()
|
|
149
|
+
|
|
150
|
+
## Public methods
|
|
151
|
+
@classmethod
|
|
152
|
+
def get_full_dotted_class_path(cls) -> str:
|
|
153
|
+
"""
|
|
154
|
+
Return full dotted class path to be used on import functions.
|
|
155
|
+
|
|
156
|
+
Example:
|
|
157
|
+
'everysk.core.BaseObject'
|
|
158
|
+
"""
|
|
159
|
+
return f'{cls.__module__}.{cls.__name__}'
|
|
160
|
+
|
|
161
|
+
def to_native(self, *, add_class_path: str | None = None, recursion: bool = False) -> Any:
|
|
162
|
+
"""
|
|
163
|
+
Converts the object to the specified Python type.
|
|
164
|
+
This method is used inside the serialization process to convert the object to a native Python type.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
add_class_path (str | None, optional): The class path to add when converting the object. Defaults to None.
|
|
168
|
+
recursion (bool, optional): Indicates whether to recursively convert nested objects. Defaults to False.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
object: The converted object.
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
return self.to_dict(add_class_path=add_class_path, recursion=recursion)
|
|
175
|
+
|
|
176
|
+
def to_dict(self, *, add_class_path: bool = False, recursion: bool = False) -> dict:
|
|
177
|
+
"""
|
|
178
|
+
Legacy method used to convert the object to a dictionary.
|
|
179
|
+
If add_class_path is True, the full doted class path will be added to the dictionary.
|
|
180
|
+
If recursion is True, the method will call the to_dict method of the child objects.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
add_class_path (bool, optional): Flag to add the class path in the result. Defaults to False.
|
|
184
|
+
recursion (bool, optional): Flag to transform the children too. Defaults to False.
|
|
185
|
+
"""
|
|
186
|
+
excluded_keys = self._to_dict_excluded_keys()
|
|
187
|
+
# If no special processing is needed, get a shallow copy of the object
|
|
188
|
+
if not recursion and not excluded_keys:
|
|
189
|
+
dct = self.copy()
|
|
190
|
+
|
|
191
|
+
# If there are excluded keys but no recursion, filter them out
|
|
192
|
+
elif not recursion:
|
|
193
|
+
dct = {key: value for key, value in self.items() if key not in excluded_keys}
|
|
194
|
+
|
|
195
|
+
# If recursion is needed, process each field accordingly filtering excluded keys
|
|
196
|
+
else:
|
|
197
|
+
# Import here to avoid circular imports because BaseObject also imports BaseMapping
|
|
198
|
+
# to transform objects to dict in the same way
|
|
199
|
+
from everysk.core.object import BaseObject # noqa: PLC0415
|
|
200
|
+
|
|
201
|
+
dct = {}
|
|
202
|
+
for key, value in self.items():
|
|
203
|
+
if key in excluded_keys:
|
|
204
|
+
continue
|
|
205
|
+
|
|
206
|
+
if not isinstance(value, (BaseMapping, BaseObject)):
|
|
207
|
+
dct[key] = value
|
|
208
|
+
else:
|
|
209
|
+
dct[key] = value.to_dict(add_class_path=add_class_path, recursion=recursion)
|
|
210
|
+
|
|
211
|
+
if add_class_path:
|
|
212
|
+
dct['__class_path__'] = self.get_full_dotted_class_path()
|
|
213
|
+
|
|
214
|
+
return dct
|