Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

dictset.__getattr__ handles missing attribute correctly now. #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nefertari/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def setup(cls, settings):
connection_class=ESHttpConnection, **params)
log.info('Including Elasticsearch. %s' % cls.settings)

except KeyError as e:
except AttributeError as e:
raise Exception(
'Bad or missing settings for elasticsearch. %s' % e)

Expand Down
5 changes: 4 additions & 1 deletion nefertari/utils/dictset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def remove(self, keys):
return dictset([[k, v] for k, v in self.items() if k not in only])

def __getattr__(self, key):
return self[key]
if key in self:
return self[key]
else:
raise AttributeError("No such attribute: %s" % key)

def __setattr__(self, key, val):
self[key] = val
Expand Down