Migrator - display some error message for unhandled schemas

Noticed it was resulting in error below migrating to IFC4X3 in some cases as we don't have a mapping for IFC4X3 yet.
```
    if value is None and not attribute.optional():
UnboundLocalError: local variable 'value' referenced before assignment
```
This commit is contained in:
Andrej730
2024-01-15 16:13:35 +05:00
parent 30b51b93af
commit f8d38b11e6
@@ -243,6 +243,7 @@ class Migrator:
def migrate_attribute(self, attribute, element, new_file, new_element, new_element_schema):
# print("Migrating attribute", element, new_element, attribute.name())
old_file = element.wrapped_data.file
if hasattr(element, attribute.name()):
value = getattr(element, attribute.name())
# print("Attribute names matched", value)
@@ -282,6 +283,16 @@ class Migrator:
)
return # We tried our best
try:
value
except UnboundLocalError:
print(
f"Couldn't match attribute {attribute.name()} by name to migrate from {element} "
f"to {new_element} and there is no special mapping to handle migration "
f"from {old_file.schema} -> {new_file.schema}"
)
return
# print("Continuing migration of {} to migrate from {} to {}".format(attribute.name(), element, new_element))
if value is None and not attribute.optional():
value = self.generate_default_value(attribute, new_file)