python-datamodel 0.10.9__tar.gz → 0.10.10__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.
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/PKG-INFO +1 -1
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/models.py +22 -9
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/version.py +1 -1
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/PKG-INFO +1 -1
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/CHANGELOG.md +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/CONTRIBUTING.md +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/LICENSE +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/MANIFEST.in +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/Makefile +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/README.md +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/SECURITY.md +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/abstract.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/adaptive/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/adaptive/models.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/aliases/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/base.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/converters.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/converters.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/converters.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/exceptions.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/exceptions.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/exceptions.pxd +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/exceptions.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/fields.cpp +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/fields.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/fields.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/functions.cpp +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/functions.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/functions.pxd +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/functions.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/jsonld/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/jsonld/models.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/mapping.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/mapping.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/mapping.pxd +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/mapping.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/libs/mutables.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/parsers/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/parsers/encoders.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/parsers/json.cpp +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/parsers/json.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/parsers/json.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/profiler.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/py.typed +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_core/Cargo.toml +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_core/src/lib.rs +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_parsers/Cargo.toml +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_parsers/src/lib.rs +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_validators/Cargo.toml +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/rs_validators/src/lib.rs +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/singleton.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/singleton.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/singleton.pxd +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/singleton.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/types.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/types.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/types.pxd +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/typedefs/types.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/types.c +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/types.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/types.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/validation.cpp +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/validation.html +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/datamodel/validation.pyx +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/pyproject.toml +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/SOURCES.txt +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/dependency_links.txt +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/not-zip-safe +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/requires.txt +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/top_level.txt +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/setup.cfg +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/setup.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/__init__.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_aliases.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_classdict.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_converter.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_dashboards.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_data.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_descriptors.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_dict.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_field.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_inherit.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_json.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_method.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_model.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_notify.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_primitives.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_qsdriver.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_qsmodel.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_qsobject.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_ticket.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_tickets.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_tuples.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_type_user.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_types.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_unions.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_valid_callables.py +0 -0
- {python_datamodel-0.10.9 → python_datamodel-0.10.10}/tests/test_validations.py +0 -0
|
@@ -230,15 +230,18 @@ class ModelMixin:
|
|
|
230
230
|
) -> dict[str, Any]:
|
|
231
231
|
"""Recursively converts any BaseModel instances to their primary key value."""
|
|
232
232
|
out = {}
|
|
233
|
-
|
|
234
|
-
for name, field in
|
|
233
|
+
_fields = self.columns()
|
|
234
|
+
for name, field in _fields.items():
|
|
235
235
|
# datatype = field.type
|
|
236
236
|
value = getattr(self, name)
|
|
237
237
|
if value is None and remove_nulls:
|
|
238
238
|
continue
|
|
239
239
|
if isinstance(value, ModelMixin):
|
|
240
240
|
if as_values:
|
|
241
|
-
|
|
241
|
+
try:
|
|
242
|
+
out[name] = getattr(value, name)
|
|
243
|
+
except AttributeError:
|
|
244
|
+
out[name] = value.to_json()
|
|
242
245
|
else:
|
|
243
246
|
out[name] = value.__collapse_as_values__(
|
|
244
247
|
remove_nulls=remove_nulls,
|
|
@@ -247,11 +250,21 @@ class ModelMixin:
|
|
|
247
250
|
)
|
|
248
251
|
# if it's a list, might contain submodels or scalars
|
|
249
252
|
elif isinstance(value, list):
|
|
253
|
+
if field.origin is list and field.args:
|
|
254
|
+
submodel_class = field.args[0] # The type inside the list
|
|
255
|
+
if issubclass(
|
|
256
|
+
submodel_class, ModelMixin
|
|
257
|
+
) and not hasattr(submodel_class, name):
|
|
258
|
+
out[name] = json_encoder(value)
|
|
259
|
+
continue
|
|
250
260
|
items_out = []
|
|
251
261
|
for item in value:
|
|
252
262
|
if isinstance(item, ModelMixin):
|
|
253
263
|
if as_values:
|
|
254
|
-
|
|
264
|
+
try:
|
|
265
|
+
items_out.append(getattr(item, name))
|
|
266
|
+
except AttributeError:
|
|
267
|
+
items_out.append(item.to_json())
|
|
255
268
|
else:
|
|
256
269
|
items_out.append(item.__collapse_as_values__(
|
|
257
270
|
remove_nulls=remove_nulls,
|
|
@@ -391,7 +404,7 @@ class ModelMixin:
|
|
|
391
404
|
@classmethod
|
|
392
405
|
def _build_fields(cls, title: str, locale: Any = None) -> dict:
|
|
393
406
|
"""Build the fields part of the schema."""
|
|
394
|
-
|
|
407
|
+
_fields = {}
|
|
395
408
|
required = []
|
|
396
409
|
defs = {}
|
|
397
410
|
|
|
@@ -400,12 +413,12 @@ class ModelMixin:
|
|
|
400
413
|
field_schema, field_defs, field_required = cls._process_field_schema(
|
|
401
414
|
name, field, locale, title
|
|
402
415
|
)
|
|
403
|
-
|
|
416
|
+
_fields[name] = field_schema
|
|
404
417
|
if field_required:
|
|
405
418
|
required.append(name)
|
|
406
419
|
if field_defs:
|
|
407
420
|
defs[name] = field_defs.get('schema')
|
|
408
|
-
return
|
|
421
|
+
return _fields, required, defs
|
|
409
422
|
|
|
410
423
|
@classmethod
|
|
411
424
|
def _extract_field_basics(cls, name: str, field: Field, title: str):
|
|
@@ -623,7 +636,7 @@ class ModelMixin:
|
|
|
623
636
|
endpoint_kwargs = {"endpoint": endpoint} if endpoint else {}
|
|
624
637
|
|
|
625
638
|
# Build the fields part of the schema.
|
|
626
|
-
|
|
639
|
+
_fields, required, defs = cls._build_fields(title, locale)
|
|
627
640
|
|
|
628
641
|
base_schema = {
|
|
629
642
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -636,7 +649,7 @@ class ModelMixin:
|
|
|
636
649
|
"type": "object",
|
|
637
650
|
"table": table,
|
|
638
651
|
"schema": schema,
|
|
639
|
-
"properties":
|
|
652
|
+
"properties": _fields,
|
|
640
653
|
"required": required,
|
|
641
654
|
"display_name": display_name,
|
|
642
655
|
}
|
|
@@ -6,7 +6,7 @@ __description__ = (
|
|
|
6
6
|
'simple library based on python +3.8 to use Dataclass-syntax'
|
|
7
7
|
'for interacting with Data'
|
|
8
8
|
)
|
|
9
|
-
__version__ = '0.10.
|
|
9
|
+
__version__ = '0.10.10'
|
|
10
10
|
__copyright__ = 'Copyright (c) 2020-2024 Jesus Lara'
|
|
11
11
|
__author__ = 'Jesus Lara'
|
|
12
12
|
__author_email__ = 'jesuslarag@gmail.com'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_datamodel-0.10.9 → python_datamodel-0.10.10}/python_datamodel.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|