From 8c70067076b76d81f8a7fd8694198b166733bd96 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 20 Jan 2020 17:24:01 -0800 Subject: [PATCH] Add .new() for adding keys to rw configs --- amanuensis/config/loader.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/amanuensis/config/loader.py b/amanuensis/config/loader.py index 63d5d17..4cef7d1 100644 --- a/amanuensis/config/loader.py +++ b/amanuensis/config/loader.py @@ -20,6 +20,12 @@ class AttrOrderedDict(OrderedDict): raise AttributeError(key) 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): """An ordered dictionary that cannot be modified"""