def setup(argdict): '''Analyze argument dictionary, return (mode, args, config) where mode is a string, args is a list of strings and config is a dictionary of configuration variables with variable name as key.''' # did user request help or version info? if argdict.has_key('--help'): return ('help', None, None) if argdict.has_key('--version'): return ('version', None, None) if argdict.has_key('--copyright'): return ('copyright', None, None) elif argdict.has_key('--config-file'): config_file = argdict['--config-file'][0] else: config_file = config.DEFAULT_CONFIG_FILE silent = 0 full = True if argdict.has_key('--silent'): silent = 1 # Some operations does not require location of latest.rdf: if argdict.has_key('--import-key') or \ argdict.has_key('--delete-key') or \ argdict.has_key('--list-keys'): full = False configuration = None try: configuration = config.parse(config_file, silent, full) except ex.io_error, errmsg: raise ex.setup_error, 'Unable to open config file: %s' % errmsg
def _init_config(self): "Initialize config," self.config = config.parse() if self.quiet: self.config["loglevel"] = log.LOGLEVEL_QUIET else: self.config["loglevel"] = log.LOGLEVEL_NORMAL self.config["cachedir"] = os.path.join(os.path.expanduser("~"), ".rdfgen/cache") self.config["tmpdir"] = os.path.join(os.path.expanduser("~"), ".rdfgen/spool")