mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user