MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / __call__

Method __call__

src/ifctester/ifctester/facet.py:305–388  ·  view source on GitHub ↗
(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None)

Source from the content-addressed store, hash-verified

303 return results
304
305 def __call__(self, inst: ifcopenshell.entity_instance, logger: Optional[Logger] = None) -> AttributeResult:
306 if isinstance(self.name, str):
307 names = [self.name]
308 attribute_type = inst.wrapped_data.get_attribute_category(self.name)
309 if attribute_type == 1: # Forward attribute
310 values = [getattr(inst, self.name, None)]
311 else:
312 values = []
313 else:
314 info = inst.get_info()
315 names = []
316 values = []
317 for k, v in info.items():
318 if k == self.name:
319 attribute_type = inst.wrapped_data.get_attribute_category(k)
320 if attribute_type == 1: # Forward attribute
321 names.append(k)
322 values.append(v)
323
324 is_pass = bool(values)
325 reason = None
326
327 if not is_pass:
328 if self.cardinality == "optional":
329 return AttributeResult(True)
330 reason = {"type": "NOVALUE"}
331
332 if is_pass:
333 non_empty_values = []
334 for i, value in enumerate(values):
335 is_empty = False
336 if value is None:
337 is_empty = True
338 elif value == "":
339 is_empty = True
340 elif value == tuple():
341 is_empty = True
342 else:
343 argument_index = inst.wrapped_data.get_argument_index(names[i])
344 try:
345 attribute_type = inst.attribute_type(argument_index)
346 if attribute_type == "LOGICAL" and value == "UNKNOWN":
347 is_empty = True
348 except:
349 if names[i] in inst.wrapped_data.get_inverse_attribute_names():
350 is_empty = True
351 if not is_empty:
352 non_empty_values.append(value)
353 if non_empty_values:
354 values = non_empty_values
355 else:
356 is_pass = False
357 reason = {"type": "FALSEY", "actual": values if len(values) > 1 else values[0]}
358
359 if is_pass and self.value:
360 for value in values:
361 if isinstance(value, ifcopenshell.entity_instance):
362 is_pass = False

Callers

nothing calls this directly

Calls 7

AttributeResultClass · 0.85
cast_to_valueFunction · 0.85
attribute_typeMethod · 0.80
is_xFunction · 0.70
get_infoMethod · 0.45
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected