def __getitem__(self, key): try: return NestedDict.__getitem__(self, key) except KeyError, e: if self.section_name is None: section = 'global section' else: section = 'section [%s]' % self.section_name raise KeyError( "Key %r not found in %s" % (key, section))
def __init__(self, configs=None, mutable=False, nest=True, section_name=None, master=None): self.section_name = section_name self.master = master NestedDict.__init__(self, configs=configs, mutable=mutable, nest=nest)