"""Stack of configuration files."""
def __init__(self, base=None):
- ## FIXME: Do we need to duplicate the config files themselves?
if base:
self.stk = base.stk[:]
else:
self.stk = []
self.in_progress = {}
- self.reset_cache()
-
- def reset_cache(self):
- self.cache = {}
def push(self, cfg):
self.stk.append(cfg)
- self.reset_cache()
def __getitem__(self, k):
- if self.cache.has_key(k):
- return self.cache[k]
if self.in_progress.has_key(k):
raise MoeConfigEvalError, "Definition of $%s is recursive" % k;
self.in_progress[k] = 1;
v = self.do_get(k, len(self.stk)-1)
del self.in_progress[k]
- ## FIXME: This is disabled, because the immutability invariant is broken!
- # self.cache[k] = v
return v
def do_get(self, k, pos):
else:
newstk.append(cfg)
self.stk = newstk
- self.reset_cache()
def parse_overrides(argv):
cfg = None