diff configuration/configuration.py @ 131:dff886188b55

minor fixes
author Jeff Hammel <k0scist@gmail.com>
date Sun, 30 Mar 2014 19:27:41 -0700
parents ee8fcdda1fd2
children f01d351ccf2b
line wrap: on
line diff
--- a/configuration/configuration.py	Sun Mar 30 19:12:00 2014 -0700
+++ b/configuration/configuration.py	Sun Mar 30 19:27:41 2014 -0700
@@ -31,6 +31,7 @@
            'TypeCastException',
            'ConfigurationOption']
 
+
 ### exceptions
 
 class UnknownOptionException(Exception):
@@ -65,15 +66,11 @@
         else:
             f = filename
             newfile = False
-        exception = None
         try:
             self._write(f, config)
-        except Exception, exception:
-            pass
-        if newfile:
-            f.close()
-        if exception:
-            raise exception
+        finally:
+            if newfile:
+                f.close()
     def _write(self, fp, config):
         raise NotImplementedError("Abstract base class")
 
@@ -85,7 +82,6 @@
             return json.loads(file(filename).read())
         def _write(self, fp, config):
             fp.write(json.dumps(config, indent=self.indent, sort_keys=True))
-            # TODO: could use templates to get order down, etc
     configuration_providers.append(JSON())
 
 if yaml:
@@ -132,6 +128,7 @@
             parser.parsed = dict()
         parser.parsed[dest] = value
 
+
 ### plugins for option types
 
 class BaseCLI(object):
@@ -157,6 +154,7 @@
     def take_action(self, value):
         return value
 
+
 class BoolCLI(BaseCLI):
 
     def __call__(self, name, value):