mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 21:42:28 +00:00
black
This commit is contained in:
@@ -197,9 +197,7 @@ class entity_instance_mixin:
|
|||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
# get_argument_index returns 0xFFFFFFFF if attribute is not found
|
# get_argument_index returns 0xFFFFFFFF if attribute is not found
|
||||||
if index == 0xFFFFFFFF:
|
if index == 0xFFFFFFFF:
|
||||||
raise AttributeError(
|
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key))
|
||||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key)
|
|
||||||
)
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def __getitem__(self, key: int) -> Any:
|
def __getitem__(self, key: int) -> Any:
|
||||||
@@ -215,7 +213,6 @@ class entity_instance_mixin:
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def __eq__(self, other: entity_instance_mixin) -> bool:
|
def __eq__(self, other: entity_instance_mixin) -> bool:
|
||||||
if not isinstance(self, type(other)):
|
if not isinstance(self, type(other)):
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -232,8 +232,10 @@ class Transaction:
|
|||||||
else:
|
else:
|
||||||
assert_never(operation["action"])
|
assert_never(operation["action"])
|
||||||
|
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
def consume_buffer(val, inner):
|
def consume_buffer(val, inner):
|
||||||
while val:
|
while val:
|
||||||
s = struct.unpack("@q", val[:8])[0]
|
s = struct.unpack("@q", val[:8])[0]
|
||||||
@@ -506,13 +508,13 @@ class file_mixin:
|
|||||||
|
|
||||||
registry = {}
|
registry = {}
|
||||||
|
|
||||||
def post_init(self, iden = None):
|
def post_init(self, iden=None):
|
||||||
if iden is None:
|
if iden is None:
|
||||||
iden = int(self.this)
|
iden = int(self.this)
|
||||||
if state := self.registry.get(iden):
|
if state := self.registry.get(iden):
|
||||||
self.state = state
|
self.state = state
|
||||||
else:
|
else:
|
||||||
self.state = self.registry[iden] = [[],[],None]
|
self.state = self.registry[iden] = [[], [], None]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def history(self):
|
def history(self):
|
||||||
@@ -699,7 +701,6 @@ class file_mixin:
|
|||||||
else:
|
else:
|
||||||
raise TypeError("Indexing into file requires either an integral number or compressed guid string")
|
raise TypeError("Indexing into file requires either an integral number or compressed guid string")
|
||||||
|
|
||||||
|
|
||||||
def add(self, inst: ifcopenshell.entity_instance, _id: int = None) -> ifcopenshell.entity_instance:
|
def add(self, inst: ifcopenshell.entity_instance, _id: int = None) -> ifcopenshell.entity_instance:
|
||||||
"""Adds an entity including any dependent entities to an IFC file.
|
"""Adds an entity including any dependent entities to an IFC file.
|
||||||
If the entity already exists, it is not re-added. Existence of entity is checked by it's `.identity()`.
|
If the entity already exists, it is not re-added. Existence of entity is checked by it's `.identity()`.
|
||||||
|
|||||||
@@ -507,9 +507,7 @@ def create_shape(
|
|||||||
"""
|
"""
|
||||||
return wrap_shape_creation(
|
return wrap_shape_creation(
|
||||||
settings,
|
settings,
|
||||||
ifcopenshell_wrapper.create_shape(
|
ifcopenshell_wrapper.create_shape(settings, inst, repr if repr is not None else None, geometry_library),
|
||||||
settings, inst, repr if repr is not None else None, geometry_library
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -430,9 +430,7 @@ class sqlite_entity(entity_instance):
|
|||||||
self.sqlite_wrapper.inverse_attribute_cache[name] = tuple(results)
|
self.sqlite_wrapper.inverse_attribute_cache[name] = tuple(results)
|
||||||
return self.sqlite_wrapper.inverse_attribute_cache[name]
|
return self.sqlite_wrapper.inverse_attribute_cache[name]
|
||||||
|
|
||||||
raise AttributeError(
|
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
||||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
|
||||||
)
|
|
||||||
|
|
||||||
def unserialise_value(self, value):
|
def unserialise_value(self, value):
|
||||||
if isinstance(value, (tuple, list)):
|
if isinstance(value, (tuple, list)):
|
||||||
|
|||||||
@@ -387,9 +387,7 @@ try:
|
|||||||
self.stream_wrapper.inverse_attribute_cache[name] = tuple(results)
|
self.stream_wrapper.inverse_attribute_cache[name] = tuple(results)
|
||||||
return self.stream_wrapper.inverse_attribute_cache[name]
|
return self.stream_wrapper.inverse_attribute_cache[name]
|
||||||
|
|
||||||
raise AttributeError(
|
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
||||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
|
||||||
)
|
|
||||||
|
|
||||||
def __eq__(self, other: stream_entity) -> bool:
|
def __eq__(self, other: stream_entity) -> bool:
|
||||||
if not isinstance(self, type(other)):
|
if not isinstance(self, type(other)):
|
||||||
|
|||||||
@@ -639,9 +639,7 @@ def set_element_value(
|
|||||||
except:
|
except:
|
||||||
# Try to cast
|
# Try to cast
|
||||||
data_type = ifcopenshell.util.attribute.get_primitive_type(
|
data_type = ifcopenshell.util.attribute.get_primitive_type(
|
||||||
element.declaration()
|
element.declaration().as_entity().attribute_by_index(element.get_argument_index(key))
|
||||||
.as_entity()
|
|
||||||
.attribute_by_index(element.get_argument_index(key))
|
|
||||||
)
|
)
|
||||||
if data_type == "string":
|
if data_type == "string":
|
||||||
value = str(value)
|
value = str(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user