changeset 20:057ccfe310b2

finish basic form of .ini factory - that was easy
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 06 Jun 2011 07:33:37 -0700
parents 8987867698ee
children 4f7c05630f36
files pyloader/factory.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pyloader/factory.py	Mon May 30 10:55:55 2011 -0700
+++ b/pyloader/factory.py	Mon Jun 06 07:33:37 2011 -0700
@@ -2,6 +2,7 @@
 abstract factories
 """
 
+import cast
 import loader
 import os
 from ConfigParser import InterpolationMissingOptionError
@@ -107,17 +108,27 @@
 
             # sanity check
             assert ':' in section, "No : in section: %s" % section
+
+            # make a dict for the section
             name, path = section.split(':', 1)
             sect = config[name] = dict(path=path)
+
+            # read the options
             for option in parser.options(section):
 
                 if option in parser.defaults():
                     # don't include the defaults
                     continue
+
+                # try to interpolate the option
+                # otherwise, use the raw value
                 try:
                     value = parser.get(section, option)
                 except (InterpolationMissingOptionError, InterpolationSyntaxError):
                     value = parser.get(section, option, raw=True)
-                                                                
-                
+
+                if option = '.': # positional arguments
+                    sect['args'] = cast.str2list(value)
+                else:
+                    sect.setdefault('kwargs', {})[option] = value