changeset 26:e547679d4bfd

this now works
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 06 Jun 2011 10:54:33 -0700
parents 8aabb54129a7
children 4b757f73e8ca
files pyloader/factory.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pyloader/factory.py	Mon Jun 06 09:55:14 2011 -0700
+++ b/pyloader/factory.py	Mon Jun 06 10:54:33 2011 -0700
@@ -9,6 +9,7 @@
 import os
 import sys
 from optparse import OptionParser
+from ConfigParser import InterpolationDepthError
 from ConfigParser import InterpolationMissingOptionError
 from ConfigParser import InterpolationSyntaxError
 from ConfigParser import SafeConfigParser as ConfigParser
@@ -119,6 +120,7 @@
 
             # make a dict for the section
             name, path = section.split(':', 1)
+            path = path % parser.defaults()
             sect = config[name] = dict(path=path)
 
             # read the options
@@ -132,7 +134,7 @@
                 # otherwise, use the raw value
                 try:
                     value = parser.get(section, option)
-                except (InterpolationMissingOptionError, InterpolationSyntaxError):
+                except (InterpolationMissingOptionError, InterpolationSyntaxError, InterpolationDepthError):
                     value = parser.get(section, option, raw=True)
 
                 if option == '.': # positional arguments
@@ -144,7 +146,8 @@
 
 def main(args=sys.argv[1:]):
     """command line entry point"""
-    parser = OptionParser()
+    usage = '%prog file1.ini -arg1 -arg2 --key1=value1 --key2=value2'
+    parser = OptionParser(usage=usage)
     options, args = parser.parse_args(args)
 
     if len(args) != 1:
@@ -152,7 +155,8 @@
         parser.exit()
 
     factory = IniFactory(args[0])
-    print factory.load()
+    obj = factory.load()
+    print obj
 
 if __name__ == '__main__':
     main()