def project_info(command_options, args): """ Usage: zanata project info [OPTIONS] Show infomation about a project Options: --project-id: project id --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_id = "" project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") url = process_url(project_config, command_options) get_version(url, command_options) if command_options.has_key('project_id'): project_id = command_options['project_id'][0]['value'] else: if project_config: project_id = project_config['project_id'] if not project_id: log.error('Please use zanata project info --project-id=project_id or zanata.xml to specify the project id') sys.exit(1) zanatacmd = ZanataCommand(url) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() zanatacmd.project_info(project_id)
def version_info(command_options, args): """ Usage: zanata version info [OPTIONS] Show infomation about a version Options: --project-id: project id --project-version: id of project version --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_id = "" iteration_id = "" project_config = read_project_config(command_options) if not project_config: log.info( "Can not find zanata.xml, please specify the path of zanata.xml") else: project_id = project_config['project_id'] iteration_id = project_config['project_version'] url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) headers = http_headers(username, apikey, 'application/vnd.zanata.Version+json') get_version(url, command_options, headers) if command_options.has_key('project_id'): project_id = command_options['project_id'][0]['value'] if command_options.has_key('project_version'): iteration_id = command_options['project_version'][0]['value'] if not iteration_id or not project_id: log.error( "Please use zanata version info --project-id=project_id --project-version=project_version to retrieve the version" ) sys.exit(1) headers = http_headers(username, apikey, 'application/json') zanatacmd = ZanataCommand(url, headers=headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() zanatacmd.version_info(project_id, iteration_id)
def version_info(command_options, args): """ Usage: zanata version info [OPTIONS] Show infomation about a version Options: --project-id: project id --project-version: id of project version --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_id = "" iteration_id = "" project_config = read_project_config(command_options) if not project_config: log.info("Can not find zanata.xml, please specify the path of zanata.xml") else: project_id = project_config['project_id'] iteration_id = project_config['project_version'] url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) headers = http_headers(username,apikey,'application/vnd.zanata.Version+json') get_version(url, command_options,headers) if command_options.has_key('project_id'): project_id = command_options['project_id'][0]['value'] if command_options.has_key('project_version'): iteration_id = command_options['project_version'][0]['value'] if not iteration_id or not project_id: log.error("Please use zanata version info --project-id=project_id --project-version=project_version to retrieve the version") sys.exit(1) headers = http_headers(username,apikey,'application/json') zanatacmd = ZanataCommand(url,headers=headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() zanatacmd.version_info(project_id, iteration_id)
def glossary_delete(command_options, args): lang = None optionsutil = OptionsUtil(command_options) url, username, apikey = optionsutil.apply_configfiles() get_version(url, command_options) log.info("Username: %s" % username) zanatacmd = ZanataCommand(url, username, apikey) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() if command_options.has_key('lang'): lang = command_options['lang'][0]['value'].split(',')[0] log.info("Delete the glossary terms in %s on the server" % lang) else: log.info("Delete all the glossary terms on the server") zanatacmd.delete_glossary(url, username, apikey, lang)
def list_project(command_options, args): """ Usage: zanata list [OPTIONS] List all available projects Options: --url address of the Zanata server, eg http://example.com/zanata --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_config = read_project_config(command_options) url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) headers = http_headers(username,apikey,'application/json') zanatacmd = ZanataCommand(url,username,apikey,headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() headers = http_headers(username,apikey,'application/vnd.zanata.Version+json') get_version(url, command_options,headers) zanatacmd.list_projects()
def list_project(command_options, args): """ Usage: zanata list [OPTIONS] List all available projects Options: --url address of the Zanata server, eg http://example.com/zanata --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_config = read_project_config(command_options) url = process_url(project_config, command_options) get_version(url, command_options) zanatacmd = ZanataCommand(url) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() zanatacmd.list_projects()
def glossary_delete(command_options, args): lang = None optionsutil = OptionsUtil(command_options) url, username, apikey = optionsutil.apply_configfiles() headers = http_headers(username, apikey, 'application/vnd.zanata.Version+json') get_version(url, command_options, headers) log.info("Username: %s" % username) zanatacmd = ZanataCommand(url, username, apikey) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() if command_options.has_key('lang'): lang = command_options['lang'][0]['value'].split(',')[0] log.info("Delete the glossary terms in %s on the server" % lang) else: log.info("Delete all the glossary terms on the server") zanatacmd.delete_glossary(url, username, apikey, lang)
def list_project(command_options, args): """ Usage: zanata list [OPTIONS] List all available projects Options: --url address of the Zanata server, eg http://example.com/zanata --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ project_config = read_project_config(command_options) url = process_url(project_config, command_options) username, apikey = read_user_config(url, command_options) headers = http_headers(username, apikey, 'application/json') zanatacmd = ZanataCommand(url, username, apikey, headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() headers = http_headers(username, apikey, 'application/vnd.zanata.Version+json') get_version(url, command_options, headers) zanatacmd.list_projects()
def glossary_push(command_options, args): """ Usage: zanata glossary push [OPTIONS] GLOSSARY_POFILE Push glossary file in po/csv format to zanata server Options: --url: URL of zanata server --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --lang(po format): language of glossary file --sourcecommentsastarget(po format): treat extracted comments and references as target comments of term or treat as source reference of entry --commentcols(csv format): comments header of csv format glossary file --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ locale_map = [] optionsutil = OptionsUtil(command_options) url, username, apikey = optionsutil.apply_configfiles() headers = http_headers(username,apikey,'application/vnd.zanata.Version+json') get_version(url, command_options,headers) log.info("Username: %s" % username) headers = http_headers(username,apikey,'application/json') zanatacmd = ZanataCommand(url, username, apikey,headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() if args: path = os.path.join(os.getcwd(), args[0]) if not os.path.isfile(path): log.error("Can not find glossary file %s under current path"%args[0]) sys.exit(1) else: log.info("Please specify the file name of glossary file") sys.exit(1) basename, extension = os.path.splitext(path) locale_map = optionsutil.get_localemap() log.info("pushing glossary document %s to server"%args[0]) if extension == '.po': if command_options.has_key('lang'): lang = command_options['lang'][0]['value'].split(',')[0] else: log.error("Please specify the language with '--lang' option") sys.exit(1) if lang in locale_map: lang = locale_map[lang] if command_options.has_key('sourcecomments'): sourcecomments = True else: sourcecomments = False zanatacmd.poglossary_push(path, url, username, apikey, lang, sourcecomments) elif extension == '.csv': if command_options.has_key('comment_cols'): comments_header = command_options['comment_cols'][0]['value'].split(',') else: log.error("Please specify the comments header, otherwise processing will be fault") sys.exit(1) zanatacmd.csvglossary_push(path, url, username, apikey, locale_map, comments_header)
def glossary_push(command_options, args): """ Usage: zanata glossary push [OPTIONS] GLOSSARY_POFILE Push glossary file in po/csv format to zanata server Options: --url: URL of zanata server --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --lang(po format): language of glossary file --sourcecommentsastarget(po format): treat extracted comments and references as target comments of term or treat as source reference of entry --commentcols(csv format): comments header of csv format glossary file --disable-ssl-cert disable ssl certificate validation in 0.7.x python-httplib2 """ locale_map = [] optionsutil = OptionsUtil(command_options) url, username, apikey = optionsutil.apply_configfiles() headers = http_headers(username, apikey, 'application/vnd.zanata.Version+json') get_version(url, command_options, headers) log.info("Username: %s" % username) headers = http_headers(username, apikey, 'application/json') zanatacmd = ZanataCommand(url, username, apikey, headers) if command_options.has_key('disablesslcert'): zanatacmd.disable_ssl_cert_validation() if args: path = os.path.join(os.getcwd(), args[0]) if not os.path.isfile(path): log.error("Can not find glossary file %s under current path" % args[0]) sys.exit(1) else: log.info("Please specify the file name of glossary file") sys.exit(1) basename, extension = os.path.splitext(path) locale_map = optionsutil.get_localemap() log.info("pushing glossary document %s to server" % args[0]) if extension == '.po': if command_options.has_key('lang'): lang = command_options['lang'][0]['value'].split(',')[0] else: log.error("Please specify the language with '--lang' option") sys.exit(1) if lang in locale_map: lang = locale_map[lang] if command_options.has_key('sourcecomments'): sourcecomments = True else: sourcecomments = False zanatacmd.poglossary_push(path, url, username, apikey, lang, sourcecomments) elif extension == '.csv': if command_options.has_key('comment_cols'): comments_header = command_options['comment_cols'][0][ 'value'].split(',') else: log.error( "Please specify the comments header, otherwise processing will be fault" ) sys.exit(1) zanatacmd.csvglossary_push(path, url, username, apikey, locale_map, comments_header)