pyetp 0.0.46__py3-none-any.whl → 0.0.47__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.
rddms_io/data_types.py ADDED
@@ -0,0 +1,11 @@
1
+ import typing
2
+
3
+ from energistics.etp.v12.datatypes.object import Edge, Resource
4
+
5
+
6
+ class LinkedObjects(typing.NamedTuple):
7
+ start_uri: str
8
+ source_resources: list[Resource]
9
+ source_edges: list[Edge]
10
+ target_resources: list[Resource]
11
+ target_edges: list[Edge]
@@ -10271,6 +10271,41 @@ class AbstractObject_1:
10271
10271
  "constructing the object."
10272
10272
  )
10273
10273
 
10274
+ @classmethod
10275
+ def get_domain_version(cls) -> str:
10276
+ namespace = getattr(cls.Meta, "namespace", None) or getattr(
10277
+ cls.Meta, "target_namespace"
10278
+ )
10279
+
10280
+ if namespace == "http://www.energistics.org/energyml/data/resqmlv2":
10281
+ return "resqml20"
10282
+ elif namespace == "http://www.energistics.org/energyml/data/commonv2":
10283
+ return "eml20"
10284
+
10285
+ raise NotImplementedError(
10286
+ f"Namespace {namespace} from object {cls} is not supported"
10287
+ )
10288
+
10289
+ @classmethod
10290
+ def get_qualified_type(cls) -> str:
10291
+ return cls.get_domain_version() + f".{cls.__name__}"
10292
+
10293
+ def get_etp_data_object_uri(self, dataspace_path_or_uri: str) -> str:
10294
+ qualified_type = self.get_qualified_type()
10295
+ identifier = (
10296
+ self.uuid
10297
+ if self.object_version is None
10298
+ else f"uuid={self.uuid},version='{self.object_version}'"
10299
+ )
10300
+ data_object_part = f"{qualified_type}({identifier})"
10301
+
10302
+ if not dataspace_path_or_uri or dataspace_path_or_uri == "eml:///":
10303
+ return f"eml:///{data_object_part}"
10304
+ elif dataspace_path_or_uri.startswith("eml:///dataspace"):
10305
+ return f"{dataspace_path_or_uri}/{data_object_part}"
10306
+
10307
+ return f"eml:///dataspace('{dataspace_path_or_uri}')/{data_object_part}"
10308
+
10274
10309
 
10275
10310
  @dataclass(slots=True, kw_only=True)
10276
10311
  class ActivityOfRadioactivityMeasure:
@@ -24107,7 +24142,7 @@ class obj_Grid2dRepresentation(AbstractSurfaceRepresentation):
24107
24142
  unit_vec_2: Annotated[npt.NDArray[np.float64], dict(shape=(2,))],
24108
24143
  patch_index: int = 0,
24109
24144
  path_in_hdf_file: str = "",
24110
- uuid: str | uuid.UUID = uuid.uuid4(),
24145
+ uuid: str | uuid.UUID | None = None,
24111
24146
  surface_role: SurfaceRole | str = SurfaceRole.MAP,
24112
24147
  boundaries: list[PatchBoundaries] | None = None,
24113
24148
  represented_interpretation: AbstractFeatureInterpretation | None = None,
@@ -24123,7 +24158,14 @@ class obj_Grid2dRepresentation(AbstractSurfaceRepresentation):
24123
24158
  necessary (a local crs, and an epc-reference file) and/or optional
24124
24159
  metadata from RESQML.
24125
24160
  """
24126
- uuid = str(uuid)
24161
+
24162
+ if uuid is None:
24163
+ # Cursed solution as the `uuid`-argument overwrites the top-level
24164
+ # import of the standard-library `uuid`.
24165
+ import uuid
24166
+
24167
+ uuid = str(uuid.uuid4())
24168
+
24127
24169
  surface_role = SurfaceRole(surface_role)
24128
24170
  boundaries = boundaries or []
24129
24171
  extra_metadata = extra_metadata or []
@@ -1,3 +1,7 @@
1
+ import typing
2
+ import warnings
3
+ from dataclasses import fields
4
+
1
5
  import resqml_objects.v201 as ro
2
6
 
3
7
  resqml_schema_version = "2.0.1"
@@ -9,6 +13,12 @@ def get_content_type_string(
9
13
  resqml_schema_version: str = resqml_schema_version,
10
14
  common_schema_version: str = common_schema_version,
11
15
  ) -> str:
16
+ warnings.warn(
17
+ "The 'get_content_type_string'-function is deprecated and will be removed in "
18
+ "a future version of pyetp. Either use it directly from "
19
+ "'DataObjectReference.get_content_type_string', or let 'DataObjectReference' "
20
+ "handle it where it is needed (under 'resqml_object.v201')."
21
+ )
12
22
  # See Energistics Identifier Specification 4.0 (it is downloaded alongside
13
23
  # the RESQML v2.0.1 standard) section 4.1 for an explanation on the format
14
24
  # of content_type.
@@ -44,3 +54,31 @@ def get_data_object_reference(
44
54
  uuid=obj.uuid,
45
55
  version_string=obj.citation.version_string,
46
56
  )
57
+
58
+
59
+ def find_hdf5_datasets(
60
+ obj: ro.AbstractCitedDataObject,
61
+ ) -> list[ro.Hdf5Dataset]:
62
+ return _find_hdf5_datasets(obj)
63
+
64
+
65
+ def _find_hdf5_datasets(obj: typing.Any) -> list[ro.Hdf5Dataset]:
66
+ hds = []
67
+
68
+ if isinstance(obj, list):
69
+ for _obj in obj:
70
+ hds.extend(_find_hdf5_datasets(_obj))
71
+ return hds
72
+
73
+ try:
74
+ _fields = fields(obj)
75
+ except TypeError:
76
+ return hds
77
+
78
+ for f in _fields:
79
+ if isinstance(getattr(obj, f.name), ro.Hdf5Dataset):
80
+ hds.append(getattr(obj, f.name))
81
+ else:
82
+ hds.extend(_find_hdf5_datasets(getattr(obj, f.name)))
83
+
84
+ return hds
@@ -1,22 +0,0 @@
1
- pyetp/__init__.py,sha256=nh-eVYEWMMxqx4YZLzN7fV7NXwbutr1soD_ot48860U,283
2
- pyetp/_version.py,sha256=Zfksky0dIFN2RZprnAMflcd2YbMf3D0JpTlHasmdh24,706
3
- pyetp/client.py,sha256=7cCDUURjWRBcmR94hbnwrLfzQoiAUV4KO0qIptQ0Hx4,57935
4
- pyetp/config.py,sha256=uGEx6n-YF7Rtgwckf0ovRKNOKgCUsiQx4IA0Tyiqafk,870
5
- pyetp/resqml_objects.py,sha256=j00e8scSh-yYv4Lpp9WjzLiaKqJWd5Cs7ROcJcxxFVw,50721
6
- pyetp/types.py,sha256=zOfUzEQcgBvveWJyM6dD7U3xJ4SCkWElewNL0Ml-PPY,6761
7
- pyetp/uri.py,sha256=zbwAeyqLgRqgN-xAbOYmiTtHtVJwfveaMbjl7yc2ifU,3143
8
- pyetp/utils_arrays.py,sha256=P9F_FWxf9IkqMI1CDdoRjKqD1bWB5DCOJWdHrT7UHfQ,13251
9
- pyetp/utils_xml.py,sha256=qETAMooFWXBvV_SIMGv1TEG2tLWCbgPraARkftqblKw,6444
10
- pyetp-0.0.46.dist-info/licenses/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
- resqml_objects/__init__.py,sha256=ilimTrQScFryxHrfZwZURVpW0li19bVnayUcHR7S_Fs,183
12
- resqml_objects/epc_readers.py,sha256=-k2GGK8VgVoqX3-ThyLjs_5OlgNHu1Sd4LZAq6YSF18,3306
13
- resqml_objects/parsers.py,sha256=aX7W4sP68NlEp8bFB88A8mXWpBHmr79ahpvgD04vCdY,724
14
- resqml_objects/serializers.py,sha256=wgWhO7ynn51cWRvt5BKdLvxZRqWuopoHFQn0tX8d2NA,1155
15
- resqml_objects/surface_helpers.py,sha256=-x9DqCliI0dUP4ierTypVFWx7eOH_0j6iDdLxzpGPtk,11207
16
- resqml_objects/v201/__init__.py,sha256=yL3jWgkyGAzr-wt_WJDV_eARE75NoA6SPEKBrKM4Crk,51630
17
- resqml_objects/v201/generated.py,sha256=vr9fRNen5GmU75g7PlX1hgusJ4vD_K1nMueV-XgTMis,789217
18
- resqml_objects/v201/utils.py,sha256=WiywauiJRBWhdjUvbKhpltRjoBX3qWd7qQ0_FAmIzUc,1442
19
- pyetp-0.0.46.dist-info/METADATA,sha256=xuiA72Cwtb83H1kpdhdRlCY1MiwE23K9YweoYfqDFaI,3096
20
- pyetp-0.0.46.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
21
- pyetp-0.0.46.dist-info/top_level.txt,sha256=NrdXbidkT5QR4NjH6nv2Frixknqse3jZq7bnqNdVb5k,21
22
- pyetp-0.0.46.dist-info/RECORD,,