mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
typing
This commit is contained in:
@@ -259,7 +259,7 @@ class Usecase:
|
||||
subelement_queue.extend(self.settings["library"].traverse(subelement, max_levels=1)[1:])
|
||||
return new
|
||||
|
||||
def has_whitelisted_inverses(self, element):
|
||||
def has_whitelisted_inverses(self, element: ifcopenshell.entity_instance) -> bool:
|
||||
for source_class, attributes in self.whitelisted_inverse_attributes.items():
|
||||
if not element.is_a(source_class):
|
||||
continue
|
||||
@@ -274,6 +274,7 @@ class Usecase:
|
||||
return True
|
||||
elif value:
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_inverses(self, element: ifcopenshell.entity_instance) -> None:
|
||||
for source_class, attributes in self.whitelisted_inverse_attributes.items():
|
||||
@@ -318,7 +319,7 @@ class Usecase:
|
||||
if new_attribute is not None:
|
||||
new[i] = new_attribute
|
||||
|
||||
def is_another_asset(self, element):
|
||||
def is_another_asset(self, element: ifcopenshell.entity_instance) -> bool:
|
||||
if element == self.settings["element"]:
|
||||
return False
|
||||
elif element.is_a("IfcFeatureElement"):
|
||||
@@ -332,7 +333,7 @@ class Usecase:
|
||||
return True
|
||||
return False
|
||||
|
||||
def reuse_existing_contexts(self):
|
||||
def reuse_existing_contexts(self) -> None:
|
||||
added_contexts = set([e for e in self.added_elements.values() if e.is_a("IfcGeometricRepresentationContext")])
|
||||
added_contexts -= set(self.existing_contexts)
|
||||
for added_context in added_contexts:
|
||||
@@ -344,7 +345,9 @@ class Usecase:
|
||||
for added_context in added_contexts:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, added_context)
|
||||
|
||||
def get_equivalent_existing_context(self, added_context):
|
||||
def get_equivalent_existing_context(
|
||||
self, added_context: ifcopenshell.entity_instance
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
for context in self.existing_contexts:
|
||||
if context.is_a() != added_context.is_a():
|
||||
continue
|
||||
@@ -361,7 +364,7 @@ class Usecase:
|
||||
):
|
||||
return context
|
||||
|
||||
def create_equivalent_context(self, added_context):
|
||||
def create_equivalent_context(self, added_context: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||
if added_context.is_a("IfcGeometricRepresentationSubContext"):
|
||||
parent = self.get_equivalent_existing_context(added_context.ParentContext)
|
||||
if not parent:
|
||||
|
||||
Reference in New Issue
Block a user