Commit 94a6850b authored by Torben Miny's avatar Torben Miny
Browse files

Merge branch fix/aasx_file_absolute_uri with refs/heads/master into refs/merge-requests/54/train

parents 0ae7a41d 492ab7ef
Pipeline #339097 passed with stage
in 47 seconds
...@@ -232,6 +232,13 @@ class AASXReader: ...@@ -232,6 +232,13 @@ class AASXReader:
if isinstance(element, model.File): if isinstance(element, model.File):
if element.value is None: if element.value is None:
continue continue
# Only absolute-path references and relative-path URI references (see RFC 3986, sec. 4.2) are considered
# to refer to files within the AASX package. Thus, we must skip all other types of URIs (esp. absolute
# URIs and network-path references)
if element.value.startswith('//') or ':' in element.value.split('/')[0]:"Skipping supplementary file %s, since it seems to be an absolute URI or network-path "
"URI reference", element.value)
absolute_name = pyecma376_2.package_model.part_realpath(element.value, part_name) absolute_name = pyecma376_2.package_model.part_realpath(element.value, part_name)
logger.debug("Reading supplementary file {} from AASX package ...".format(absolute_name)) logger.debug("Reading supplementary file {} from AASX package ...".format(absolute_name))
with self.reader.open_part(absolute_name) as p: with self.reader.open_part(absolute_name) as p:
...@@ -408,7 +415,9 @@ class AASXWriter: ...@@ -408,7 +415,9 @@ class AASXWriter:
for element in traversal.walk_submodel(submodel): for element in traversal.walk_submodel(submodel):
if isinstance(element, model.File): if isinstance(element, model.File):
file_name = element.value file_name = element.value
if file_name is None: # Skip File objects with empty value URI references that are considered to be no local file (absolute
# URIs or network-path URI references)
if file_name is None or file_name.startswith('//') or ':' in file_name.split('/')[0]:
continue continue
try: try:
content_type = file_store.get_content_type(file_name) content_type = file_store.get_content_type(file_name)
...@@ -379,6 +379,23 @@ def create_example_submodel() -> model.Submodel: ...@@ -379,6 +379,23 @@ def create_example_submodel() -> model.Submodel:
qualifier=None, qualifier=None,
kind=model.ModelingKind.INSTANCE) kind=model.ModelingKind.INSTANCE)
submodel_element_file_uri = model.File(
description={'en-us': 'Details of the Asset Administration Shell—An example for an external file reference',
'de': 'Details of the Asset Administration Shell – Ein Beispiel für eine extern referenzierte '
submodel_element_reference_element = model.ReferenceElement( submodel_element_reference_element = model.ReferenceElement(
id_short='ExampleReferenceElement', id_short='ExampleReferenceElement',
value=model.AASReference((model.Key(type_=model.KeyElements.PROPERTY, value=model.AASReference((model.Key(type_=model.KeyElements.PROPERTY,
...@@ -535,6 +552,7 @@ def create_example_submodel() -> model.Submodel: ...@@ -535,6 +552,7 @@ def create_example_submodel() -> model.Submodel:
id_short='ExampleSubmodelCollectionUnordered', id_short='ExampleSubmodelCollectionUnordered',
value=(submodel_element_blob, value=(submodel_element_blob,
submodel_element_file, submodel_element_file,
submodel_element_reference_element), submodel_element_reference_element),
category='PARAMETER', category='PARAMETER',
description={'en-us': 'Example SubmodelElementCollectionUnordered object', description={'en-us': 'Example SubmodelElementCollectionUnordered object',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment