Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class AttrDict(dict):
"""
Dict with class style attribute access.
"""
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
class FrozenAttrDict(frozendict):
"""
Frozendict with class style attribute access.
"""
__getattr__ = frozendict.__getitem__
class DefAttrDict(AttrDict):
"""
AttrDict with support for default values, which must be a AttrDict.
"""
def __init__(self, data, defaults=None):
super(DefAttrDict, self).__init__(data)
if defaults is None:
defaults = AttrDict()
self.__defaults__ = defaults
def __getattr__(self, key):
try:
return super(DefAttrDict, self).__getattr__(key)
except KeyError: