From 9a607498123cae7f055fb55d18ee53f1db84c9eb Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Tue, 7 Sep 2010 13:30:22 +0200 Subject: [PATCH] Added shorthand access moe.ConfTree[key] to conf --- t/moe/conf.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/moe/conf.py b/t/moe/conf.py index c745961..00e0b5a 100644 --- a/t/moe/conf.py +++ b/t/moe/conf.py @@ -24,8 +24,10 @@ TODO (OPT): Implemet "subtree" listing. import types, itertools, re, bisect import logging as log + from moe import MoeError + "Allowed depth of recursion - includes ALL recursive calls, so should quite high." c_maxdepth = 256 @@ -35,6 +37,7 @@ debug_maxdepth = 0 "Variable name regexp, dots (separators) must be separated from edges and each other." re_VARNAME = re.compile(r'\A([A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+\Z') + def check_depth(depth): "Helper to check for recursion depth." global debug_maxdepth @@ -83,6 +86,12 @@ class ConfigTree(object): self.variables[key] = ConfigVar(key) return self.variables[key] + def __getitem__(self, key) + """ + Return the value of an existing variable. + """ + return self.lookup(key, create=False).value() + def dump(self, prefix=''): """ Pretty printing of the tree. -- 2.39.2