mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 21:38:12 +00:00
Check for numbers.Integral instead of int, to catch py2.7's long type as well
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import numbers
|
||||||
import platform
|
import platform
|
||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
@@ -66,7 +67,7 @@ class entity_instance(object):
|
|||||||
is_instance = lambda e: isinstance(e, entity_instance)
|
is_instance = lambda e: isinstance(e, entity_instance)
|
||||||
return entity_instance.walk(is_instance, unwrap, v)
|
return entity_instance.walk(is_instance, unwrap, v)
|
||||||
def attribute_type(self, attr):
|
def attribute_type(self, attr):
|
||||||
attr_idx = attr if isinstance(attr, int) else self.wrapped_data.get_argument_index(attr)
|
attr_idx = attr if isinstance(attr, numbers.Integral) else self.wrapped_data.get_argument_index(attr)
|
||||||
return self.wrapped_data.get_argument_type(attr_idx)
|
return self.wrapped_data.get_argument_type(attr_idx)
|
||||||
def attribute_name(self, attr_idx):
|
def attribute_name(self, attr_idx):
|
||||||
return self.wrapped_data.get_argument_name(attr_idx)
|
return self.wrapped_data.get_argument_name(attr_idx)
|
||||||
@@ -110,7 +111,7 @@ class file(object):
|
|||||||
if attr[0:6] == 'create': return functools.partial(self.create_entity,attr[6:])
|
if attr[0:6] == 'create': return functools.partial(self.create_entity,attr[6:])
|
||||||
else: return getattr(self.wrapped_data, attr)
|
else: return getattr(self.wrapped_data, attr)
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if isinstance(key, int):
|
if isinstance(key, numbers.Integral):
|
||||||
return entity_instance(self.wrapped_data.by_id(key))
|
return entity_instance(self.wrapped_data.by_id(key))
|
||||||
elif isinstance(key, str):
|
elif isinstance(key, str):
|
||||||
return entity_instance(self.wrapped_data.by_guid(key))
|
return entity_instance(self.wrapped_data.by_guid(key))
|
||||||
|
|||||||
Reference in New Issue
Block a user