Add .new() for adding keys to rw configs
This commit is contained in:
parent
085ac63da8
commit
8c70067076
|
@ -20,6 +20,12 @@ class AttrOrderedDict(OrderedDict):
|
||||||
raise AttributeError(key)
|
raise AttributeError(key)
|
||||||
self[key] = value
|
self[key] = value
|
||||||
|
|
||||||
|
def new(self, key, value):
|
||||||
|
"""Setter for adding new keys"""
|
||||||
|
if key in self:
|
||||||
|
raise KeyError("Key already exists: '{}'".format(key))
|
||||||
|
self[key] = value
|
||||||
|
|
||||||
|
|
||||||
class ReadOnlyOrderedDict(OrderedDict):
|
class ReadOnlyOrderedDict(OrderedDict):
|
||||||
"""An ordered dictionary that cannot be modified"""
|
"""An ordered dictionary that cannot be modified"""
|
||||||
|
|
Loading…
Reference in New Issue