Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
updated configure interface to do most of the parsing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Richter authored and Felix Richter committed Jan 24, 2011
1 parent d87b32d commit 7de4b3f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions genericore/utils.py
Expand Up @@ -39,15 +39,37 @@ def load_conf_parser(self,parser):
""" loads the configuration from a parser object """

class Configurator(Configurable):
def __init__(self,PROTO_VERSION,conf=None):
def __init__(self,PROTO_VERSION,DESCRIPTION,conf=None):
""" PROTO_VERSION is the protocol version of the module to configure """
Configurable.__init__(self,conf)
self.PROTO_VERSION = PROTO_VERSION
self.DESCRIPTION = DESCRIPTION

def configure(self,conf_list):
""" configures all configurable objects with current config """
""" configures all configurable objects with current config
Steps:
1. load DEFAULT CONFIG (implicitly loaded when instanciating)
2. load Config File (in eval_parser of self)
3. load Parameters (in every eval_parser)
Each step may overwrite already existing keys in config
"""
parser = argparse.ArgumentParser(description=self.DESCRIPTION)

self.populate_parser(parser)
for configurable in conf_list:
configurable.populate_parser(parser)

args = parser.parse_args()

self.eval_parser(args)
for i in conf_list:
i.load_conf(self.config)
i.eval_parser(args)

self.blend(conf_list)
log.debug ('New Configuration:' + str(self.config))

def blend(self,conf_list):
""" blends all configurations of all configurables into this object """
Expand Down

0 comments on commit 7de4b3f

Please sign in to comment.