Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions server/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import pathlib
import sys

from basyx.aas import model, adapter
from basyx.aas.adapter import aasx
from basyx.aas import model
from basyx.aas.adapter.aasx import AASXReader, DictSupplementaryFileContainer
from basyx.aas.adapter.json import read_aas_json_file_into
from basyx.aas.adapter.xml import read_aas_xml_file_into

from basyx.aas.backend.local_file import LocalFileObjectStore
from interfaces.repository import WSGIApp
Expand All @@ -18,11 +20,11 @@
wsgi_optparams["base_path"] = base_path

if storage_type == "LOCAL_FILE_BACKEND":
application = WSGIApp(LocalFileObjectStore(storage_path), aasx.DictSupplementaryFileContainer(), **wsgi_optparams)
application = WSGIApp(LocalFileObjectStore(storage_path), DictSupplementaryFileContainer(), **wsgi_optparams)

elif storage_type in "LOCAL_FILE_READ_ONLY":
elif storage_type == "LOCAL_FILE_READ_ONLY":
object_store: model.DictObjectStore = model.DictObjectStore()
file_store: aasx.DictSupplementaryFileContainer = aasx.DictSupplementaryFileContainer()
file_store: DictSupplementaryFileContainer = DictSupplementaryFileContainer()

for file in pathlib.Path(storage_path).iterdir():
if not file.is_file():
Expand All @@ -31,12 +33,12 @@

if file.suffix.lower() == ".json":
with open(file) as f:
adapter.json.read_aas_json_file_into(object_store, f)
read_aas_json_file_into(object_store, f)
elif file.suffix.lower() == ".xml":
with open(file) as f:
adapter.xml.read_aas_xml_file_into(object_store, file)
read_aas_xml_file_into(object_store, f)
elif file.suffix.lower() == ".aasx":
with aasx.AASXReader(file) as reader:
with AASXReader(file) as reader:
reader.read_into(object_store=object_store, file_store=file_store)

application = WSGIApp(object_store, file_store, **wsgi_optparams)
Expand Down