# HG changeset patch
# User Jeff Hammel <jhammel@mozilla.com>
# Date 1379485343 25200
# Node ID c6a41a60afc03ba6d00d5c6392254a372fc096c0
# Parent  5db2844b83009bd6defd219bd5065fe9d4cb9512
configuration/configuration.py

diff -r 5db2844b8300 -r c6a41a60afc0 configuration/configuration.py
--- a/configuration/configuration.py	Tue Sep 17 20:47:50 2013 -0700
+++ b/configuration/configuration.py	Tue Sep 17 23:22:23 2013 -0700
@@ -109,6 +109,7 @@
 
 __all__.extend([i.__class__.__name__ for i in configuration_providers])
 
+
 ### optparse interface
 
 class ConfigurationOption(optparse.Option):
@@ -240,6 +241,13 @@
     load_option = 'load' # where to put the load option
     load_help = "load configuration from a file"
 
+    @classmethod
+    def parse(cls, args, *_args, **_kwargs):
+        """get the resultant config dictionary in a single call"""
+        conf = cls(*_args, **_kwargs)
+        conf.parse_args(*_args, **_kwargs)
+        return conf.config
+
     def __init__(self, configuration_providers=configuration_providers, types=types, load=None, dump='--dump', **parser_args):
 
         # sanity check
@@ -358,6 +366,12 @@
                 defaults[key] = value['default']
         return copy.deepcopy(defaults)
 
+    def get(self, key, default=None):
+        return self.config.get(key, default)
+
+    def __getitem__(self, key):
+        return self.config[key]
+
     def __call__(self, *args):
         """add items to configuration and check it"""
         # TODO: configuration should be locked after this is called