diff --git a/hydrolib/tools/ext_old_to_new/converters.py b/hydrolib/tools/ext_old_to_new/converters.py index 0ef49bdd5..aa71815c9 100644 --- a/hydrolib/tools/ext_old_to_new/converters.py +++ b/hydrolib/tools/ext_old_to_new/converters.py @@ -109,17 +109,24 @@ def convert(self, forcing: ExtOldForcing) -> Boundary: """ data = { "quantity": forcing.quantity, - "nodeid": "aNodeId", - "locationFile": forcing.filename, + "locationfile": forcing.filename, "forcingfile": ForcingModel(), } # HINT: not sure if these keywords exists in the old external files or they are new so they are not expected # here and these following lines should be removed. - if "bndwidth1d" in forcing.__dict__: - data["bndwidth1d"] = forcing.bndwidth1d - if "bndbldepth" in forcing.__dict__: - data["bndbldepth"] = forcing.bndwidth2d + nodeid = getattr(forcing, "nodeid", None) + if nodeid: + data["nodeid"] = nodeid + + bndwidth1d = getattr(forcing, "bndwidth1d", None) + bndbldepth = getattr(forcing, "bndbldepth", None) + + if bndwidth1d: + data["bndwidth1d"] = bndwidth1d + + if bndbldepth: + data["bndbldepth"] = bndbldepth new_block = Boundary(**data) diff --git a/tests/tools/test_converters.py b/tests/tools/test_converters.py index 2f68443a8..3f3a0481c 100644 --- a/tests/tools/test_converters.py +++ b/tests/tools/test_converters.py @@ -67,6 +67,6 @@ def test_default(self): assert new_quantity_block.quantity == "waterlevelbnd" assert new_quantity_block.forcingfile == ForcingModel() assert new_quantity_block.locationfile == DiskOnlyFileModel(file_name) - assert new_quantity_block.nodeid == "aNodeId" + assert new_quantity_block.nodeid is None assert new_quantity_block.bndwidth1d is None assert new_quantity_block.bndbldepth is None