Skip to content

Commit 08880b4

Browse files
committed
Small fixes
1 parent 21c37ce commit 08880b4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

__init__.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def enumeration(self, s):
235235
subsuper_record = list
236236
INT = int
237237
REAL = float
238-
NONE = str
238+
NONE = lambda *args: None
239239
STAR = str
240240

241241

@@ -247,8 +247,11 @@ class entity_instance:
247247
lines: tuple
248248

249249
def __getitem__(self, k):
250-
# compatibility with dict
251-
return getattr(self, k)
250+
if isinstance(k, numbers.Integral):
251+
return self.attributes[k]
252+
else:
253+
# compatibility with dict
254+
return getattr(self, k)
252255

253256
def __repr__(self):
254257
return f'#{self.id}={self.type}({",".join(map(str, self.attributes))})'
@@ -359,8 +362,10 @@ def replace_fn(match):
359362
# Even in this case we do want to report duplicate identifiers
360363
# so these need to be captured
361364
methods["id"] = lambda self, *args: args
362-
methods["simple_entity_instance"] = lambda self, tree: instance_identifiers.append(
363-
(int(tree[0][0][0][1:]), int(tree[0][0][0].line))
365+
methods["simple_entity_instance"] = (
366+
lambda self, tree: instance_identifiers.append(
367+
(int(tree[0][0][0][1:]), int(tree[0][0][0].line))
368+
)
364369
)
365370

366371
NT = type("NullTransformer", (Transformer,), methods)
@@ -450,7 +455,7 @@ def by_id(self, id: int) -> entity_instance:
450455
raise RuntimeError(f"Instance with id {id} not found")
451456
elif len(ns) > 1:
452457
raise RuntimeError(f"Duplicate definition for id {id}")
453-
return entity_instance(ns, ns[0])
458+
return ns[0]
454459

455460
def by_type(self, type: str) -> list[entity_instance]:
456461
"""Return IFC objects filtered by IFC Type and wrapped with the entity_instance class.

0 commit comments

Comments
 (0)