Skip to content

Commit

Permalink
recurse on gets too for now
Browse files Browse the repository at this point in the history
  • Loading branch information
akatrevorjay committed Mar 2, 2019
1 parent 8c7be0a commit e20cc68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pytutils/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,12 @@ def _wrap_as(cls):
def __getattr__(self, key):
if not key.startswith('_'):
try:
val = self.__mapping[key]
return val
value = self.__mapping[key]

if self.__recursion and isinstance(value, collections.Mapping) and not isinstance(value, self._wrap_as):
value = self.__class__(value)

return value
except KeyError:
# in py3 I'd chain these
raise AttributeError(key)
Expand Down

0 comments on commit e20cc68

Please sign in to comment.