# HG changeset patch # User Jeff Hammel # Date 1294801942 28800 # Node ID a6aff990985bfdbc25ca32798da4e0d801d3ae55 # Parent ad5fd3eb667461e512862a72dc0cf24c704ca6df do rudimentary interpretation of config files diff -r ad5fd3eb6674 -r a6aff990985b makeitso/makeitso.py --- a/makeitso/makeitso.py Tue Jan 11 16:30:52 2011 -0800 +++ b/makeitso/makeitso.py Tue Jan 11 19:12:22 2011 -0800 @@ -14,6 +14,7 @@ import urllib # TODO: may have to use urllib2.urlopen to get reasonable timeouts +from ConfigParser import RawConfigParser from optparse import OptionParser # URL of -this file- @@ -372,6 +373,18 @@ ### command line interface +def read_config(config_files, templates=()): + """read variables from a set of .ini files""" + retval = {} + parser = RawConfigParser() + parser.read(config_files) + retval.update(dict(parser.items('DEFAULT'))) + for template in templates: + if template in parser.sections(): + retval.update(dict(parser.items(template))) + + return retval + def invocation(url, **variables): """returns a string appropriate for TTW invocation""" variables_string = ' '.join(['%s=%s' % (i,j) for i,j in variables.items()]) @@ -383,6 +396,13 @@ usage = '%prog [options] template