Created
November 29, 2016 22:02
-
-
Save cfobel/de6e84b5d266bf2e47f6385935eaf8c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See also [here][1]. | |
# | |
# [1]: http://robot-framework.readthedocs.io/en/latest/_modules/robot/utils/dotdict.html | |
class DotOrderedDict(OrderedDict): | |
def __getattr__(self, attr): | |
try: | |
result = super(DotOrderedDict, self).__getattribute__(attr) | |
return result | |
except AttributeError: | |
if attr == '_OrderedDict__root': | |
raise | |
return self.get(attr, None) | |
def __setattr__(self, attr, value): | |
if attr.startswith('_'): | |
super(DotOrderedDict, self).__setattr__(attr, value) | |
else: | |
self.__setitem__(attr, value) | |
__delattr__ = OrderedDict.__delitem__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment