27
27
correct_dor ,
28
28
)
29
29
from src .energyml .utils .xml import *
30
+ from utils .data .datasets_io import HDF5FileReader
30
31
31
32
fi_cit = Citation (
32
33
title = "An interpretation" ,
@@ -130,11 +131,7 @@ def file_test():
130
131
print (find_schema_version_in_element (get_tree (xml_content )))
131
132
print (get_class_name_from_xml (get_tree (xml_content )))
132
133
133
- print (
134
- get_class_from_name (
135
- "energyml.resqml.v2_2.resqmlv2.TriangulatedSetRepresentation"
136
- )
137
- )
134
+ print (get_class_from_name ("energyml.resqml.v2_2.resqmlv2.TriangulatedSetRepresentation" ))
138
135
139
136
print (read_energyml_xml_str (xml_content ))
140
137
print (read_energyml_xml_file (path ))
@@ -143,53 +140,27 @@ def file_test():
143
140
def tests_content_type ():
144
141
print (RGX_CONTENT_TYPE )
145
142
146
- print (
147
- parse_content_type (
148
- "application/x-resqml+xml;version=2.2;type=TriangulatedSetRepresentation"
149
- )
150
- )
151
- print (
152
- parse_content_type (
153
- "application/vnd.openxmlformats-package.core-properties+xml"
154
- ).group ("domain" )
155
- )
143
+ print (parse_content_type ("application/x-resqml+xml;version=2.2;type=TriangulatedSetRepresentation" ))
144
+ print (parse_content_type ("application/vnd.openxmlformats-package.core-properties+xml" ).group ("domain" ))
156
145
157
- print (
158
- get_class_from_content_type (
159
- "application/x-resqml+xml;version=2.2;type=TriangulatedSetRepresentation"
160
- )
161
- )
146
+ print (get_class_from_content_type ("application/x-resqml+xml;version=2.2;type=TriangulatedSetRepresentation" ))
162
147
print (
163
148
"CT 201 : " ,
164
- get_class_from_content_type (
165
- "application/x-resqml+xml;version=2.0;type=obj_HorizonInterpretation"
166
- ),
167
- )
168
- print (
169
- parse_content_type (
170
- "application/x-resqml+xml;version=2.0;type=obj_HorizonInterpretation"
171
- )
149
+ get_class_from_content_type ("application/x-resqml+xml;version=2.0;type=obj_HorizonInterpretation" ),
172
150
)
151
+ print (parse_content_type ("application/x-resqml+xml;version=2.0;type=obj_HorizonInterpretation" ))
173
152
174
- print (
175
- get_class_from_content_type (
176
- "application/vnd.openxmlformats-package.core-properties+xml"
177
- )
178
- )
153
+ print (get_class_from_content_type ("application/vnd.openxmlformats-package.core-properties+xml" ))
179
154
180
155
print (get_content_type_from_class (tr ))
181
156
print (get_qualified_type_from_class (tr ))
182
157
print (
183
158
get_qualified_type_from_class (DoubleHdf5Array ()),
184
- get_class_from_qualified_type (
185
- get_qualified_type_from_class (DoubleHdf5Array ())
186
- ),
159
+ get_class_from_qualified_type (get_qualified_type_from_class (DoubleHdf5Array ())),
187
160
)
188
161
print (
189
162
get_qualified_type_from_class (dor_correct ),
190
- get_class_from_qualified_type (
191
- get_qualified_type_from_class (dor_correct )
192
- ),
163
+ get_class_from_qualified_type (get_qualified_type_from_class (dor_correct )),
193
164
)
194
165
195
166
print (gen_energyml_object_path (tr , EpcExportVersion .EXPANDED ))
@@ -204,17 +175,11 @@ def tests_epc():
204
175
print (epc )
205
176
epc .export_file ("D:/Geosiris/Github/energyml/energyml-python/test.epc" )
206
177
epc .export_version = EpcExportVersion .EXPANDED
207
- epc .export_file (
208
- "D:/Geosiris/Github/energyml/energyml-python/test_EXPANDED.epc"
209
- )
178
+ epc .export_file ("D:/Geosiris/Github/energyml/energyml-python/test_EXPANDED.epc" )
210
179
epc .core_props = None
211
- epc .export_file (
212
- "D:/Geosiris/Github/energyml/energyml-python/test_no_core.epc"
213
- )
180
+ epc .export_file ("D:/Geosiris/Github/energyml/energyml-python/test_no_core.epc" )
214
181
215
- epc201 = Epc .read_file (
216
- "D:/Geosiris/OSDU/manifestTranslation/#Data/VOLVE_STRUCT.epc"
217
- )
182
+ epc201 = Epc .read_file ("D:/Geosiris/OSDU/manifestTranslation/#Data/VOLVE_STRUCT.epc" )
218
183
print (epc201 )
219
184
220
185
print (f"NB errors { len (validate_epc (epc201 ))} " )
@@ -239,10 +204,7 @@ def tests_dor():
239
204
240
205
print (
241
206
json .dumps (
242
- {
243
- k : [get_obj_uuid (x ) for x in v ]
244
- for k , v in get_reverse_dor_list (epc .energyml_objects ).items ()
245
- },
207
+ {k : [get_obj_uuid (x ) for x in v ] for k , v in get_reverse_dor_list (epc .energyml_objects ).items ()},
246
208
indent = 4 ,
247
209
)
248
210
)
@@ -301,16 +263,8 @@ def test_introspection():
301
263
print (search_attribute_matching_type (tr , "Citation" ))
302
264
print (search_attribute_matching_type (tr , "DataObjectreference" ))
303
265
print (search_attribute_matching_type_with_path (tr , "DataObjectreference" ))
304
- print (
305
- class_match_rgx (
306
- ContactElement , "DataObjectreference" , super_class_search = False
307
- )
308
- )
309
- print (
310
- class_match_rgx (
311
- ContactElement , "DataObjectreference" , super_class_search = True
312
- )
313
- )
266
+ print (class_match_rgx (ContactElement , "DataObjectreference" , super_class_search = False ))
267
+ print (class_match_rgx (ContactElement , "DataObjectreference" , super_class_search = True ))
314
268
print (Enum in ExistenceKind .__bases__ )
315
269
print (Enum in TriangulatedSetRepresentation .__bases__ )
316
270
print (is_primitive (int ))
@@ -331,9 +285,7 @@ def test_introspection():
331
285
print (TriangulatedSetRepresentation .__dataclass_params__ )
332
286
333
287
# print(random_value_from_class(int))
334
- print (
335
- serialize_xml (random_value_from_class (TriangulatedSetRepresentation ))
336
- )
288
+ print (serialize_xml (random_value_from_class (TriangulatedSetRepresentation )))
337
289
# print(serialize_json(random_value_from_class(TriangulatedSetRepresentation)))
338
290
339
291
print (search_attribute_matching_name_with_path (tr , "[tT]it.*" ))
@@ -342,13 +294,7 @@ def test_introspection():
342
294
print (AbstractPoint3DArray .__dict__ )
343
295
print (TriangulatedSetRepresentation .__dict__ )
344
296
print (get_sub_classes (AbstractObject ))
345
- print (
346
- list (
347
- filter (
348
- lambda _c : not is_abstract (_c ), get_sub_classes (AbstractObject )
349
- )
350
- )
351
- )
297
+ print (list (filter (lambda _c : not is_abstract (_c ), get_sub_classes (AbstractObject ))))
352
298
print (AbstractColorMap .__name__ .startswith ("Abstract" ))
353
299
print (is_abstract (AbstractColorMap ))
354
300
@@ -366,17 +312,13 @@ def test_introspection():
366
312
367
313
print (f"object: { is_abstract (object )} " )
368
314
print (f"HDF5FileReader: { is_abstract (HDF5FileReader )} " )
369
- print (
370
- f"TriangulatedSetRepresentation: { is_abstract (TriangulatedSetRepresentation )} "
371
- )
315
+ print (f"TriangulatedSetRepresentation: { is_abstract (TriangulatedSetRepresentation )} " )
372
316
373
317
# print("HDF5FileReader")
374
318
# for func in dir(HDF5FileReader):
375
319
# if callable(getattr(HDF5FileReader, func)) and not func.startswith("__"):
376
320
# print(f"\t{func} {type(getattr(HDF5FileReader, func))}")
377
- print (
378
- get_classes_matching_name (TriangulatedSetRepresentation , "Abstract.*" )
379
- )
321
+ print (get_classes_matching_name (TriangulatedSetRepresentation , "Abstract.*" ))
380
322
# print(get_matching_class_attribute_name(ExternalDataArrayPart, "(PathInHdfFile|PathInExternalFile)"))
381
323
# print(object.__module__)
382
324
# print(serialize_xml(random_value_from_class(PointSetRepresentation)))
@@ -390,21 +332,15 @@ def test_introspection():
390
332
# print(serialize_xml(poly))
391
333
392
334
print ("=====] " , r"ClosedPolylines.\d+" )
393
- for array_path , array_value in search_attribute_matching_name_with_path (
394
- poly , r"ClosedPolylines.\d+"
395
- ):
335
+ for array_path , array_value in search_attribute_matching_name_with_path (poly , r"ClosedPolylines.\d+" ):
396
336
print (f"{ array_path } \n \t { array_value } " )
397
337
398
338
print ("=====] " , r"ClosedPolylines.values.\d+" )
399
- for array_path , array_value in search_attribute_matching_name_with_path (
400
- poly , r"ClosedPolylines.values.\d+"
401
- ):
339
+ for array_path , array_value in search_attribute_matching_name_with_path (poly , r"ClosedPolylines.values.\d+" ):
402
340
print (f"{ array_path } \n \t { array_value } " )
403
341
404
342
print ("=====] " , r"LinePatch.\d+" )
405
- for array_path , array_value in search_attribute_matching_name_with_path (
406
- poly , r"LinePatch.\d+"
407
- ):
343
+ for array_path , array_value in search_attribute_matching_name_with_path (poly , r"LinePatch.\d+" ):
408
344
print (f"{ array_path } \n \t { array_value } " )
409
345
410
346
@@ -424,17 +360,15 @@ def tests_hdf():
424
360
425
361
for o in tr_list :
426
362
print (o .__class__ )
427
- print (get_hdf_reference_with_path (o ))
363
+ print (get_path_in_external_with_path (o ))
428
364
exit (0 )
429
365
430
366
431
367
def test_local_depth_crs ():
432
368
# Fails because the xsi:type="VerticalCrsEpsgCode" doesn't
433
369
# contain the namespace : xsi:type="eml:VerticalCrsEpsgCode"
434
370
try :
435
- depth3d = read_energyml_xml_file (
436
- "../rc/obj_LocalDepth3dCrs_716f6472-18a3-4f19-a57c-d4f5642ccc53.xml"
437
- )
371
+ depth3d = read_energyml_xml_file ("../rc/obj_LocalDepth3dCrs_716f6472-18a3-4f19-a57c-d4f5642ccc53.xml" )
438
372
print (serialize_json (depth3d , JSON_VERSION .XSDATA ))
439
373
print (serialize_xml (depth3d ))
440
374
except Exception as e :
@@ -445,9 +379,7 @@ def test_get_projected_uom():
445
379
# Fails because the xsi:type="VerticalCrsEpsgCode" doesn't
446
380
# contain the namespace : xsi:type="eml:VerticalCrsEpsgCode"
447
381
try :
448
- depth3d = read_energyml_xml_file (
449
- "../rc/obj_LocalDepth3dCrs_716f6472-18a3-4f19-a57c-d4f5642ccc53.xml"
450
- )
382
+ depth3d = read_energyml_xml_file ("../rc/obj_LocalDepth3dCrs_716f6472-18a3-4f19-a57c-d4f5642ccc53.xml" )
451
383
print (get_projected_uom (depth3d ).value )
452
384
except Exception as e :
453
385
print (e )
@@ -502,28 +434,18 @@ def class_field():
502
434
print (get_class_fields (tr )["citation" ])
503
435
print (get_class_pkg_version (tr ))
504
436
print (create_energyml_object ("resqml22.TriangulatedSetRepresentation" ))
505
- ext_20 = create_energyml_object (
506
- "application/x-eml+xml;version=2.0;type=obj_EpcExternalPartReference"
507
- )
437
+ ext_20 = create_energyml_object ("application/x-eml+xml;version=2.0;type=obj_EpcExternalPartReference" )
508
438
print (ext_20 )
509
439
print (gen_energyml_object_path (ext_20 ))
510
440
print (create_external_part_reference ("2.0" , "my_h5" ))
511
441
512
- print (
513
- parse_content_or_qualified_type (
514
- "application/x-eml+xml;version=2.0;type=obj_EpcExternalPartReference"
515
- )
516
- )
442
+ print (parse_content_or_qualified_type ("application/x-eml+xml;version=2.0;type=obj_EpcExternalPartReference" ))
517
443
print (
518
444
get_domain_version_from_content_or_qualified_type (
519
445
"application/x-eml+xml;version=2.0;type=obj_EpcExternalPartReference"
520
446
)
521
447
)
522
- print (
523
- get_domain_version_from_content_or_qualified_type (
524
- "resqml20.obj_EpcExternalPartReference"
525
- )
526
- )
448
+ print (get_domain_version_from_content_or_qualified_type ("resqml20.obj_EpcExternalPartReference" ))
527
449
528
450
# print(create_external_part_reference("2.2", "myfile.h5"))
529
451
# print(create_external_part_reference("2.0", "myfile.h5"))
0 commit comments