config: add some helper methods
authorMatt Mackall <mpm@selenic.com>
Sun, 26 Apr 2009 16:50:43 -0500
changeset 8186 6a0018cdb2fe
parent 8185 dc10a7a3f1d4
child 8187 d2504744e7a5
config: add some helper methods
mercurial/config.py
--- 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()