Skip to content

Commit

Permalink
simplify __getattr__
Browse files Browse the repository at this point in the history
  • Loading branch information
nanorepublica committed Jun 8, 2017
1 parent c9a4079 commit abd6af2
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions duedil/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,15 @@ def __getattr__(self, name):
"""
lazily return attributes, only contact duedil if necessary
"""
try:
return super(Resource, self).__getattribute__(name)
except AttributeError:
if name in self.attribute_names:
if not self.loaded:
try:
self.load()
except ValueError:
pass
if name in self.attribute_names:
if not self.loaded:
try:
return super(Resource, self).__getattribute__(name)
except AttributeError:
raise
else:
raise
self.load()
except ValueError:
pass
return super(Resource, self).__getattribute__(name)
else:
raise AttributeError

@property
def endpoint(self):
Expand Down

0 comments on commit abd6af2

Please sign in to comment.