mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Run black on IfcOpenShell-python.
This commit is contained in:
@@ -42,7 +42,7 @@ def set_derived_atribute(*args):
|
||||
# inherited attributes) to set that particular
|
||||
# attribute by index.
|
||||
# For example. IFC2X3.IfcWall with have a list of
|
||||
# 9 methods. The first will point at
|
||||
# 9 methods. The first will point at
|
||||
# ifcopenshell.ifcopenshell_wrapper.entity_instance.setArgumentAsString
|
||||
# because the first attribute GlobalId ultimately
|
||||
# is of type string.
|
||||
@@ -56,25 +56,28 @@ for nm in ifcopenshell_wrapper.schema_names():
|
||||
for decl in schema.declarations():
|
||||
if hasattr(decl, "argument_types"):
|
||||
fq_name = ".".join((nm, decl.name()))
|
||||
|
||||
|
||||
# get type strings as reported by IfcOpenShell C++
|
||||
type_strs = decl.argument_types()
|
||||
|
||||
|
||||
# convert case for setter function
|
||||
type_strs = [x.title().replace(" ", "") for x in type_strs]
|
||||
|
||||
|
||||
# binary and enumeration are passed from python as string as well
|
||||
type_strs = [x.replace("Binary", "String") for x in type_strs]
|
||||
type_strs = [x.replace("Enumeration", "String") for x in type_strs]
|
||||
|
||||
|
||||
# prefix to get method names
|
||||
fn_names = ["setArgumentAs" + x for x in type_strs]
|
||||
|
||||
|
||||
# resolve to actual functions in wrapper
|
||||
functions = [
|
||||
set_derived_atribute if mname == "setArgumentAsDerived" else getattr(ifcopenshell_wrapper.entity_instance, mname) \
|
||||
for mname in fn_names]
|
||||
|
||||
set_derived_atribute
|
||||
if mname == "setArgumentAsDerived"
|
||||
else getattr(ifcopenshell_wrapper.entity_instance, mname)
|
||||
for mname in fn_names
|
||||
]
|
||||
|
||||
_method_dict[fq_name] = functions
|
||||
|
||||
|
||||
@@ -177,13 +180,13 @@ class entity_instance(object):
|
||||
|
||||
if self.method_list is None:
|
||||
super(entity_instance, self).__setattr__("method_list", _method_dict[self.is_a(True)])
|
||||
|
||||
|
||||
method = self.method_list[idx]
|
||||
|
||||
|
||||
if value is None:
|
||||
if method is not set_derived_atribute:
|
||||
self.wrapped_data.setArgumentAsNull(idx)
|
||||
else:
|
||||
else:
|
||||
self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value))
|
||||
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user