Skip to content

Commit

Permalink
take into account lazy module importing which may fail
Browse files Browse the repository at this point in the history
  • Loading branch information
marinuso committed Aug 23, 2017
1 parent f20894d commit 7a0f1fb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pynapl/ObjectWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ def items(self):
for attr in dir(obj):

item = getattr(obj, attr)
if hasattr(item,'__call__'):
fn.append(attr)
else:
va.append(attr)
try:
if hasattr(item,'__call__'):
fn.append(attr)
else:
va.append(attr)
except ImportError:
# There are modules which import other modules conditionally,
# which aren't necessarily available, but which would only give
# an error if you actually tried to use it. Since this wrapper
# pokes everything, it would trap all of that, so we catch
# ImportError and ignore it. If something could not be imported,
# it is simply not included in the list of attributes.
pass

return classname, va, fn

Expand Down

0 comments on commit 7a0f1fb

Please sign in to comment.