Mercurial > hg
changeset 8186:6a0018cdb2fe
config: add some helper methods
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | dc10a7a3f1d4 |
children | d2504744e7a5 |
files | mercurial/config.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/config.py Sun Apr 26 16:50:43 2009 -0500 +++ b/mercurial/config.py Sun Apr 26 16:50:43 2009 -0500 @@ -27,7 +27,7 @@ dict.__delitem__(self, key) self._list.remove(key) -class config: +class config(object): def __init__(self, data=None): self._data = {} self._source = {} @@ -39,6 +39,11 @@ return config(self) def __contains__(self, section): return section in self._data + def __getitem__(self, section): + return self._data.get(section, {}) + def __iter__(self): + for d in self.sections(): + yield d def update(self, src, sections=None): if not sections: sections = src.sections()