Skip to content

Commit 2a12d13

Browse files
authored
Small fixes (#408)
server.app.main: Small fixes and codestyle enhancements This refactors the import statements in `main.py`, as well as fixes the reading of JSON and XML files. Both file types are now read in the same way using `FileIO` as input for `read_aas_xml_file_into`, as we already did in `read_aas_json_file_into`.
1 parent 128a2ef commit 2a12d13

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

server/app/main.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import pathlib
33
import sys
44

5-
from basyx.aas import model, adapter
6-
from basyx.aas.adapter import aasx
5+
from basyx.aas import model
6+
from basyx.aas.adapter.aasx import AASXReader, DictSupplementaryFileContainer
7+
from basyx.aas.adapter.json import read_aas_json_file_into
8+
from basyx.aas.adapter.xml import read_aas_xml_file_into
79

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

2022
if storage_type == "LOCAL_FILE_BACKEND":
21-
application = WSGIApp(LocalFileObjectStore(storage_path), aasx.DictSupplementaryFileContainer(), **wsgi_optparams)
23+
application = WSGIApp(LocalFileObjectStore(storage_path), DictSupplementaryFileContainer(), **wsgi_optparams)
2224

23-
elif storage_type in "LOCAL_FILE_READ_ONLY":
25+
elif storage_type == "LOCAL_FILE_READ_ONLY":
2426
object_store: model.DictObjectStore = model.DictObjectStore()
25-
file_store: aasx.DictSupplementaryFileContainer = aasx.DictSupplementaryFileContainer()
27+
file_store: DictSupplementaryFileContainer = DictSupplementaryFileContainer()
2628

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

3234
if file.suffix.lower() == ".json":
3335
with open(file) as f:
34-
adapter.json.read_aas_json_file_into(object_store, f)
36+
read_aas_json_file_into(object_store, f)
3537
elif file.suffix.lower() == ".xml":
3638
with open(file) as f:
37-
adapter.xml.read_aas_xml_file_into(object_store, file)
39+
read_aas_xml_file_into(object_store, f)
3840
elif file.suffix.lower() == ".aasx":
39-
with aasx.AASXReader(file) as reader:
41+
with AASXReader(file) as reader:
4042
reader.read_into(object_store=object_store, file_store=file_store)
4143

4244
application = WSGIApp(object_store, file_store, **wsgi_optparams)

0 commit comments

Comments
 (0)