@@ -235,7 +235,7 @@ def enumeration(self, s):
235
235
subsuper_record = list
236
236
INT = int
237
237
REAL = float
238
- NONE = str
238
+ NONE = lambda * args : None
239
239
STAR = str
240
240
241
241
@@ -247,8 +247,11 @@ class entity_instance:
247
247
lines : tuple
248
248
249
249
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 )
252
255
253
256
def __repr__ (self ):
254
257
return f'#{ self .id } ={ self .type } ({ "," .join (map (str , self .attributes ))} )'
@@ -359,8 +362,10 @@ def replace_fn(match):
359
362
# Even in this case we do want to report duplicate identifiers
360
363
# so these need to be captured
361
364
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
+ )
364
369
)
365
370
366
371
NT = type ("NullTransformer" , (Transformer ,), methods )
@@ -450,7 +455,7 @@ def by_id(self, id: int) -> entity_instance:
450
455
raise RuntimeError (f"Instance with id { id } not found" )
451
456
elif len (ns ) > 1 :
452
457
raise RuntimeError (f"Duplicate definition for id { id } " )
453
- return entity_instance ( ns , ns [0 ])
458
+ return ns [0 ]
454
459
455
460
def by_type (self , type : str ) -> list [entity_instance ]:
456
461
"""Return IFC objects filtered by IFC Type and wrapped with the entity_instance class.
0 commit comments