industrial-model 0.1.23__py3-none-any.whl → 0.1.24__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.
@@ -1,9 +1,11 @@
1
1
  from datetime import date, datetime
2
+ from typing import Any
2
3
 
3
4
  import cognite.client.data_classes.filters as cdf_filters
4
5
  from cognite.client.data_classes.data_modeling import MappedProperty, View
5
6
 
6
7
  from industrial_model.cognite_adapters.utils import get_property_ref
8
+ from industrial_model.models.entities import InstanceId
7
9
  from industrial_model.statements import (
8
10
  BoolExpression,
9
11
  Expression,
@@ -54,11 +56,8 @@ class FilterMapper:
54
56
  property_ref = get_property_ref(expression.property, root_view)
55
57
 
56
58
  value_ = expression.value
57
- if isinstance(value_, datetime):
58
- value_ = datetime_to_ms_iso_timestamp(value_)
59
59
 
60
- if isinstance(value_, date):
61
- value_ = value_.strftime("%Y-%m-%d")
60
+ value_ = self._handle_type_value_convertion(value_)
62
61
 
63
62
  if expression.operator == "==":
64
63
  return cdf_filters.Equals(property_ref, value_)
@@ -96,3 +95,14 @@ class FilterMapper:
96
95
  assert isinstance(view_definiton, MappedProperty)
97
96
  assert view_definiton.source
98
97
  return self._view_mapper.get_view(view_definiton.source.external_id)
98
+
99
+ def _handle_type_value_convertion(self, value_: Any) -> Any:
100
+ if isinstance(value_, datetime):
101
+ return datetime_to_ms_iso_timestamp(value_)
102
+ elif isinstance(value_, date):
103
+ return value_.strftime("%Y-%m-%d")
104
+ elif isinstance(value_, InstanceId):
105
+ return value_.model_dump(mode="json", by_alias=True)
106
+ elif isinstance(value_, list):
107
+ return [self._handle_type_value_convertion(v) for v in value_]
108
+ return value_
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 0.1.23
3
+ Version: 0.1.24
4
4
  Summary: Industrial Model ORM
5
5
  Author-email: Lucas Alves <lucasrosaalves@gmail.com>
6
6
  Classifier: Programming Language :: Python
@@ -5,7 +5,7 @@ industrial_model/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  industrial_model/utils.py,sha256=oh4AxwxXaWgIC2uolkCbvkgo0ququHB6yAPVIXy45Ts,663
6
6
  industrial_model/cognite_adapters/__init__.py,sha256=cKPW5y-wWiyWYLPDaNjhqc5zdsgdLc40vunIlz2Debg,6246
7
7
  industrial_model/cognite_adapters/aggregation_mapper.py,sha256=qglWUnyhgSPG005HzIRyjYkt9V2WKsab5y4ruwuKLcA,2503
8
- industrial_model/cognite_adapters/filter_mapper.py,sha256=xXTzxCYKU1-6TxG5W_bb8zNyWi2bfIM9RiujyOHUujg,3900
8
+ industrial_model/cognite_adapters/filter_mapper.py,sha256=R_OX8JOM33vzBVFvfo0iDmSJl5rhGjsTBLyKDoesHO0,4349
9
9
  industrial_model/cognite_adapters/models.py,sha256=2j2IS01uPkQEp9WdVk8seYzEqGcDdWFnpzXhusHB2zk,945
10
10
  industrial_model/cognite_adapters/optimizer.py,sha256=EQfCe-4mSeXhYa2kcqJerPXYsCRgMJPA1AIf1o1KNH0,2415
11
11
  industrial_model/cognite_adapters/query_mapper.py,sha256=QdFVkfmL4tWcCy_oypOluT0Fo68obPk2RjBPvVA9mUs,5950
@@ -27,6 +27,6 @@ industrial_model/queries/models.py,sha256=wn4I8bTUGCT5keF6mUA7bEYNgSsOxeN-zibY5C
27
27
  industrial_model/queries/params.py,sha256=ehgCoR5n6E-tkEuoymZ2lkLcSzMaBAx_HnyJ7sWpqz0,964
28
28
  industrial_model/statements/__init__.py,sha256=rjLRo2KoazHQaOpmPkxbI3_Nm8NCkJxjpuqow6IZVSc,4221
29
29
  industrial_model/statements/expressions.py,sha256=4ZZOcZroI5-4xRw4PXIRlufi0ARndE5zSbbxLDpR2Ec,4816
30
- industrial_model-0.1.23.dist-info/METADATA,sha256=HoA3Ba1kVrvGjtZQEqGvFHL2NnvV8G1S1uIcq7Of53c,6858
31
- industrial_model-0.1.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
- industrial_model-0.1.23.dist-info/RECORD,,
30
+ industrial_model-0.1.24.dist-info/METADATA,sha256=F8lZBHy_GghR4NABWGDlVrQdITuncMGQ0FF89ZCCHQg,6858
31
+ industrial_model-0.1.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
+ industrial_model-0.1.24.dist-info/RECORD,,