diff martini/config.py @ 11:c77259f467a3

hopefully OrderedDict preservation actually works now
author Jeff Hammel <k0scist@gmail.com>
date Tue, 23 Aug 2016 18:17:11 -0700
parents 66d11212175d
children 4faed08eb8d8
line wrap: on
line diff
--- a/martini/config.py	Tue Aug 23 09:26:27 2016 -0700
+++ b/martini/config.py	Tue Aug 23 18:17:11 2016 -0700
@@ -26,7 +26,8 @@
 
     if os.path.exists(resource):
         return file(resource)
-    if sum([resource.startswith(http) for http in 'http://', 'https://']):
+    if sum([resource.startswith(http)
+            for http in 'http://', 'https://']):
         return urllib2.urlopen(resource)
     return StringIO(resource)
 
@@ -64,13 +65,15 @@
             _section = self[section]
             self.remove_section(section)
         else:
-            _section = {}
-        self.read({newname: _section})
+            _section = OrderedDict()
+        self.read(OrderedDict(newname=_section))
 
     def dict(self):
-        """return a dictionary of dictionaries;
+        """
+        return a dictionary of dictionaries:
         the outer with keys of section names;
-        the inner with keys, values of the section"""
+        the inner with keys, values of the section
+        """
         return OrderedDict([(section, self[section])
                             for section in self.sections()])