From a69e0a27fe1615f38e6a37e8b494fe8f7e542d8d Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 24 Oct 2017 23:18:45 +0800 Subject: configs: add __getitem__() and __setitem__() methods --- fg21sim/configs/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py index 4143a8f..7912e1d 100644 --- a/fg21sim/configs/manager.py +++ b/fg21sim/configs/manager.py @@ -233,7 +233,8 @@ class ConfigManager: logger.info("Loaded user config: {0}".format(self.userconfig)) def reset(self): - """Reset the current configurations to the copy of defaults from + """ + Reset the current configurations to the copy of defaults from the specifications. NOTE: Also reset ``self.userconfig`` to ``None``. @@ -423,6 +424,12 @@ class ConfigManager: logger.info("Set config: {key}: {val_new} <- {val_old}".format( key="/".join(key), val_new=val_new, val_old=val_old)) + def __getitem__(self, key): + return self.getn(key=key) + + def __setitem__(self, key, value): + self.setn(key=key, value=value) + def get_path(self, key): """ Return the absolute path of the file/directory specified by the -- cgit v1.2.2