def parse_args(self, args=None, namespace=None): """Parse commandline arguments and construct an opts dictionary""" opts = super(AppArgumentParser, self).parse_args(args, namespace) if self.config: for section in self.config.sections(): items = dict((item.lower(), self.config.get(section, item)) for item in self.config.options(section)) opts.update({section: items}) parse_parameters(opts) return opts
def parse_args(self, args=None, namespace=None, ALLOW_UNRECOGNIZED=False): """Parse commandline arguments and construct an opts dictionary""" opts = super(AppArgumentParser, self).parse_args(args, namespace, ALLOW_UNRECOGNIZED) if self.config: for section in self.config.sections(): items = dict((item.lower(), self.config.get(section, item)) for item in self.config.options(section)) opts.update({section: items}) parse_parameters(opts) validate_configs(opts, VALIDATE_DICT) return opts
def __init__(self, config_file=None): self.config_file = config_file or resilient.get_config_file() super(OptParser, self).__init__(config_file=self.config_file) # # Note this is a trick used by resilient-circuits. resilient.ArgumentParser will # validate the arguments of the command line. Since we use command line # argument of input/output files, we don't want that validation, so we # erase them before we call parse_args(). So parse_args() only # reads from app.config # sys.argv = sys.argv[0:1] self.opts = self.parse_args() if self.config: for section in self.config.sections(): # # Handle sections other than [resilient] in app.config # items = dict((item.lower(), self.config.get(section, item)) for item in self.config.options(section)) self.opts.update({section: items}) resilient.parse_parameters(self.opts)