def read_user_config(url, command_options): user_name = "" apikey = "" config = ZanataConfig() #Try to read user-config file user_config = [ os.path.join(os.path.expanduser("~") + '/.config', filename) for filename in ['zanata.ini', 'flies.ini'] ] if command_options.has_key('user_config'): user_config.append(command_options['user_config'][0]['value']) for path in user_config: if os.path.exists(path): log.info("Loading zanata user config from: %s" % path) #Read the user-config file config.set_userconfig(path) try: server = config.get_server(url) if server: user_name = config.get_config_value( "username", "servers", server) apikey = config.get_config_value("key", "servers", server) except Exception, e: log.info("Processing user-config file:%s" % str(e)) break break
def read_project_config(self, command_options): project_config = {} config = ZanataConfig() #Read the project configuration file using --project-config option config_file = [os.path.join(os.getcwd(), filename) for filename\ in ['zanata.xml', 'flies.xml']] if command_options.has_key('project_config'): config_file.append(command_options['project_config'][0]['value']) for path in config_file: if os.path.exists(path): log.info("Loading zanata project config from: %s" % path) project_config = config.read_project_config(path) break return project_config
def __init__(self, options): self.command_options = options self.project_config = {} self.log = Logger() self.config = ZanataConfig()