mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
black
This commit is contained in:
@@ -197,9 +197,7 @@ class entity_instance_mixin:
|
||||
except IndexError as e:
|
||||
# get_argument_index returns 0xFFFFFFFF if attribute is not found
|
||||
if index == 0xFFFFFFFF:
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key)
|
||||
)
|
||||
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key))
|
||||
raise e
|
||||
|
||||
def __getitem__(self, key: int) -> Any:
|
||||
@@ -210,18 +208,17 @@ class entity_instance_mixin:
|
||||
def __setitem__(self, idx: int, value: T) -> T:
|
||||
if self.file and self.file.transaction:
|
||||
self.file.transaction.store_edit(self, idx, value)
|
||||
|
||||
|
||||
self.set_attribute_value_py(idx, value)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def __eq__(self, other: entity_instance_mixin) -> bool:
|
||||
if not isinstance(self, type(other)):
|
||||
return False
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def is_entity(self) -> bool:
|
||||
"""Tests whether the instance is an entity type as opposed to a simple data type.
|
||||
|
||||
|
||||
@@ -232,8 +232,10 @@ class Transaction:
|
||||
else:
|
||||
assert_never(operation["action"])
|
||||
|
||||
|
||||
import struct
|
||||
|
||||
|
||||
def consume_buffer(val, inner):
|
||||
while val:
|
||||
s = struct.unpack("@q", val[:8])[0]
|
||||
@@ -506,22 +508,22 @@ class file_mixin:
|
||||
|
||||
registry = {}
|
||||
|
||||
def post_init(self, iden = None):
|
||||
def post_init(self, iden=None):
|
||||
if iden is None:
|
||||
iden = int(self.this)
|
||||
if state := self.registry.get(iden):
|
||||
self.state = state
|
||||
else:
|
||||
self.state = self.registry[iden] = [[],[],None]
|
||||
self.state = self.registry[iden] = [[], [], None]
|
||||
|
||||
@property
|
||||
def history(self):
|
||||
return self.state[0]
|
||||
|
||||
|
||||
@property
|
||||
def future(self):
|
||||
return self.state[1]
|
||||
|
||||
|
||||
@property
|
||||
def transaction(self):
|
||||
return self.state[2]
|
||||
@@ -529,7 +531,7 @@ class file_mixin:
|
||||
@transaction.setter
|
||||
def transaction(self, v):
|
||||
self.state[2] = v
|
||||
|
||||
|
||||
def set_history_size(self, size: int) -> None:
|
||||
self.history_size = size
|
||||
while len(self.history) > self.history_size:
|
||||
@@ -699,7 +701,6 @@ class file_mixin:
|
||||
else:
|
||||
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:
|
||||
"""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()`.
|
||||
@@ -710,7 +711,7 @@ class file_mixin:
|
||||
|
||||
if self.transaction:
|
||||
max_id = self.getMaxId()
|
||||
|
||||
|
||||
result = self._add(inst, -1 if _id is None else _id)
|
||||
|
||||
if self.transaction:
|
||||
|
||||
@@ -507,9 +507,7 @@ def create_shape(
|
||||
"""
|
||||
return wrap_shape_creation(
|
||||
settings,
|
||||
ifcopenshell_wrapper.create_shape(
|
||||
settings, inst, repr if repr is not None else None, geometry_library
|
||||
),
|
||||
ifcopenshell_wrapper.create_shape(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)
|
||||
return self.sqlite_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
||||
)
|
||||
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
||||
|
||||
def unserialise_value(self, value):
|
||||
if isinstance(value, (tuple, list)):
|
||||
|
||||
@@ -387,9 +387,7 @@ try:
|
||||
self.stream_wrapper.inverse_attribute_cache[name] = tuple(results)
|
||||
return self.stream_wrapper.inverse_attribute_cache[name]
|
||||
|
||||
raise AttributeError(
|
||||
"entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)
|
||||
)
|
||||
raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name))
|
||||
|
||||
def __eq__(self, other: stream_entity) -> bool:
|
||||
if not isinstance(self, type(other)):
|
||||
|
||||
@@ -639,9 +639,7 @@ def set_element_value(
|
||||
except:
|
||||
# Try to cast
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(
|
||||
element.declaration()
|
||||
.as_entity()
|
||||
.attribute_by_index(element.get_argument_index(key))
|
||||
element.declaration().as_entity().attribute_by_index(element.get_argument_index(key))
|
||||
)
|
||||
if data_type == "string":
|
||||
value = str(value)
|
||||
|
||||
Reference in New Issue
Block a user