# HG changeset patch # User Jeff Hammel # Date 1307371158 25200 # Node ID 4f7c05630f36b99df1d89baf8dc2cff26f96cebb # Parent 057ccfe310b27026c3b87c9d48b9287a0d9dfc9c tie up some factory loose ends and sweeten the API with syntactic sugar diff -r 057ccfe310b2 -r 4f7c05630f36 pyloader/factory.py --- a/pyloader/factory.py Mon Jun 06 07:33:37 2011 -0700 +++ b/pyloader/factory.py Mon Jun 06 07:39:18 2011 -0700 @@ -89,18 +89,22 @@ def __init__(self, inifile, main=''): assert os.path.exists(inifile), "File not found: %s" % inifile - - def read(self): + self.inifile = inifile + config = self.read(inifile) + PyFactory.__init__(self, config, main) + + @classmethod + def read(cls, inifile): """reads configuration from an .ini file""" - here = os.path.dirname(os.path.abspath(self.inifile)) + here = os.path.dirname(os.path.abspath(inifile)) # read configuration defaults={'here': here, - 'this': os.path.abspath(self.inifile)} + 'this': os.path.abspath(inifile)} parser = ConfigParser(defaults=defaults) parser.optionxform = str # use whole case - parser.read(self.inifile) + parser.read(inifile) # parse configuration config = {} @@ -131,4 +135,8 @@ sect['args'] = cast.str2list(value) else: sect.setdefault('kwargs', {})[option] = value - + + return config + +if __name__ == '__main__': + pass