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 project_info(command_options, args): """ Usage: zanata project info [OPTIONS] Show infomation about a project Options: --project-id: 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) if command_options.has_key('project_id'): project_id = command_options['project_id'][0]['value'] else: 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) zanata = ZanataResource(url) zanatacmd = ZanataCommand() zanatacmd.project_info(zanata, project_id)
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 """ locale_map = [] zanatacmd = ZanataCommand() optionsutil = OptionsUtil(command_options) url, username, apikey = optionsutil.apply_configfiles() get_version(url) log.info("Username: %s" % username) 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 create_version(command_options, args): """ Usage: zanata version create [VERSION_ID] [OPTIONS] Create a version Options: --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-id: id of the project --version-name(Deprecated): version name --version-desc(Deprecated): version description """ project_id = "" version_name = "" version_desc = "" 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) username, apikey = read_user_config(url, command_options) server_version = get_version(url) if command_options.has_key('project_id'): project_id = command_options['project_id'][0]['value'] elif project_config.has_key('project_id'): project_id = project_config['project_id'] else: log.error("Please specify PROJECT_ID with --project-id option or using zanata.xml") log.info("Project id:%s" % project_id) if args: version_id = args[0] else: log.error("Please provide ITERATION_ID for creating iteration") sys.exit(1) if command_options.has_key('version_name'): version_name = command_options['version_name'][0]['value'] log.warn("This option is deprecated, it should not be used on new zanata server") if command_options.has_key('version_desc'): version_desc = command_options['version_desc'][0]['value'] log.warn("This option is deprecated, it should not be used on new zanata server") #if server_version: # version_number = convert_serverversion(server_version) # if version_number <= 1.2 and not version_name: # version_name = args[0] #else: # if not version_name: # version_name = args[0] zanata = generate_zanataresource(url, username, apikey) zanatacmd = ZanataCommand() zanatacmd.create_version(zanata, project_id, version_id, version_name, version_desc)
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 """ project_config = read_project_config(command_options) url = process_url(project_config, command_options) get_version(url) zanata = ZanataResource(url) zanatacmd = ZanataCommand() zanatacmd.list_projects(zanata)
def generate_zanatacmd(url, username, apikey, headers=None): if username and apikey: return ZanataCommand(url, username, apikey, headers) else: log.error( "Please specify username and apikey in zanata.ini or with '--username' and '--apikey' options" ) sys.exit(1)
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 pull(command_options, args, project_type = None): """ Usage: zanata pull [OPTIONS] {documents} {lang} Retrieve translated publican content files from server Options: --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-type: project type (gettext or podir) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --transdir: translations will be written to this folder --lang: language list (defaults to zanata.xml locales) """ dir_option = False skeletons = True filelist = [] zanatacmd = ZanataCommand() output_folder = None 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) username, apikey = read_user_config(url, command_options) get_version(url) zanata = generate_zanataresource(url, username, apikey) #if file not specified, push all the files in pot folder to zanata server project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) lang_list = get_lang_list(command_options, project_config) #list the files in project try: filelist = zanata.documents.get_file_list(project_id, iteration_id) except Exception, e: log.error(str(e)) sys.exit(1)
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 create_project(command_options, args): """ Usage: zanata project create [PROJECT_ID] [OPTIONS] Create a project Options: --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-name: project name --project-desc: project description """ project_id = "" project_name = "" project_desc = "" 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) username, apikey = read_user_config(url, command_options) get_version(url) if args: project_id = args[0] else: log.error("Please provide PROJECT_ID for creating project") sys.exit(1) if command_options.has_key('project_name'): project_name = command_options['project_name'][0]['value'] else: log.error("Please specify project name with '--project-name' option") sys.exit(1) if command_options.has_key('project_desc'): project_desc = command_options['project_desc'][0]['value'] zanata = generate_zanataresource(url, username, apikey) zanatacmd = ZanataCommand() zanatacmd.create_project(zanata, project_id, project_name, project_desc)
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 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 """ 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) get_version(url) 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) zanata = ZanataResource(url) zanatacmd = ZanataCommand() zanatacmd.version_info(zanata, 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 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_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 push(command_options, args, project_type = None): """ Usage: zanata push OPTIONS {documents} Generic push command to push content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-type: project type (gettext or podir) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --srcdir: the path of the pot folder (e.g. ./pot) --srcfile: the path of the pot file(gettext project only) --transdir: the path of the folder that contain locale folders (e.g. ./myproject) --push-trans: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list (defaults to zanata.xml locales) """ copytrans = True importpo = False force = False dir_option = False deletefiles = False plural_support = False command_type = '' tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': ''} zanatacmd = ZanataCommand() 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) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('project_type'): command_type = command_options['project_type'][0]['value'] elif project_config['project_type']: command_type = project_config['project_type'] else: log.error("The project type is unknown") sys.exit(1) if command_type != 'podir' and command_type != 'gettext': log.error("The project type is not correct, please use 'podir' and 'gettext' as project type") sys.exit(1) if command_options.has_key('srcfile'): if command_type == 'gettext': tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) else: log.warn("srcfile option is not used for podir type project, ignored") #Disable dir option for generic push command if command_options.has_key('dir'): log.warn("dir option is disabled in push command, please use --srcdir and --transdir, or specify value in zanata.xml") if command_type != 'podir' and command_type != 'gettext': log.error("The project type is unknown") sys.exit(1) if tmlfolder == "": tmlfolder = process_srcdir(command_options) if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or using zanata.xml") sys.exit(1) if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
def push(command_options, args, project_type = None): """ Usage: zanata push OPTIONS {documents} Generic push command to push content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name --apikey: api key of user --project-type: project type (software or publican) --project-id: id of the project --project-version: id of the version --srcdir: the full path of the pot folder (e.g. /home/jamesni/myproject/pot) --transdir: the full path of the folder that contain locale folders (e.g. /home/jamesni/myproject) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions """ copytrans = True importpo = False force = False command_type = '' tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': ''} zanatacmd = ZanataCommand() 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) username, apikey = read_user_config(url, command_options) get_version(url) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('project_type'): command_type = command_options['project_type'][0]['value'] elif project_type: command_type = project_type else: log.error("The project type is unknown") sys.exit(1) if command_type == 'software' and command_options.has_key('srcfile'): tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) else: tmlfolder = process_srcdir(command_options, command_type, project_config) if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or '--dir' option") sys.exit(1) if command_type == 'publican': log.info("POT directory (originals):%s" % tmlfolder) elif command_type == 'software': log.info("PO directory (originals):%s" % tmlfolder) if command_options.has_key('importpo'): log.info("Importing translation") import_param['transdir'] = process_transdir(command_options, project_config) log.info("Reading locale folders from %s" % import_param['transdir']) import_param['merge'] = process_merge(command_options) import_param['lang_list'] = get_lang_list(command_options, project_config) if project_config.has_key('locale_map'): import_param['locale_map'] = project_config['locale_map'] else: import_param['locale_map'] = None import_param['project_type'] = command_type importpo = True else: log.info("Importing source documents only") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
def po_push(command_options, args): """ Usage: zanata po push [OPTIONS] {documents} Push software project source and translation files to server Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --dir: the path of the folder that contains pot files and po files, no need to specify --srcdir and --transdir if --dir option specified --srcdir: the path of the po folder(e.g. ./po) --srcfile: the path of the source file --transdir: the path of the folder that contains po files(e.g. ./po) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list """ copytrans = True importpo = False force = False dir_option = False command_type = '' tmlfolder = "" plural_support = False filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': 'gettext'} zanatacmd = ZanataCommand() 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) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) if command_options.has_key('srcfile'): tmlfolder, import_file = process_srcfile(command_options) filelist.append(import_file) tmlfolder = process_srcdir_withsub(command_options, "gettext") if not os.path.isdir(tmlfolder): log.error("Can not find source folder, please specify the source folder with '--srcdir' or 'dir' option") sys.exit(1) log.info("PO directory (originals):%s" % tmlfolder) if command_options.has_key('importpo'): importpo = True if command_options.has_key('pushtrans'): log.info("please use --import-po for old publican push command") importpo = True if importpo: log.info("Importing translation") import_param['transdir'] = process_transdir(command_options, tmlfolder) log.info("Reading locale folders from %s" % import_param['transdir']) import_param['merge'] = process_merge(command_options) import_param['lang_list'] = get_lang_list(command_options, project_config) if project_config.has_key('locale_map'): import_param['locale_map'] = project_config['locale_map'] else: import_param['locale_map'] = None importpo = True else: log.info("Importing source documents only") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
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 publican_push(command_options, args): """ Usage: zanata publican push OPTIONS {documents} Push publican content to server for translation. Argumensts: documents Options: -f: force to remove content on server side --username: user name (defaults to zanata.ini value) --apikey: api key of user (defaults to zanata.ini value) --project-id: id of the project (defaults to zanata.xml value) --project-version: id of the version (defaults to zanata.xml value) --dir: the path of the folder that contains pot folder and locale folders, no need to specify --srcdir and --transdir if --dir option specified --srcdir: the path of the pot folder (e.g. ./pot) --transdir: the path of the folder that contain locale folders (e.g. ./myproject) --import-po: push local translations to server --merge: override merge algorithm: auto (default) or import --no-copytrans: prevent server from copying translations from other versions --lang: language list """ copytrans = True importpo = False force = False dir_option = False deletefiles = False plural_support = False tmlfolder = "" filelist = [] import_param = {'transdir': '', 'merge': 'auto', 'lang_list': {}, 'locale_map': {}, 'project_type': 'podir'} zanatacmd = ZanataCommand() 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) username, apikey = read_user_config(url, command_options) server_version = get_version(url) plural_support = check_plural_support(server_version) zanata = generate_zanataresource(url, username, apikey) project_id, iteration_id = zanatacmd.check_project(zanata, command_options, project_config) log.info("Username: %s" % username) log.info("Source language: en-US") if command_options.has_key('nocopytrans'): copytrans = False log.info("Copy previous translations:%s" % copytrans) tmlfolder = process_srcdir_withsub(command_options, "podir") if args: try: full_path = search_file(tmlfolder, args[0]) filelist.append(full_path) except NoSuchFileException, e: log.error(e.msg) sys.exit(1)
outpath = create_outpath(command_options) if project_config.has_key('locale_map'): locale_map = project_config['locale_map'] else: locale_map = None if command_options.has_key('project_type'): command_type = command_options['project_type'][0]['value'] elif project_type: command_type = project_type else: log.error("The project type is unknown") sys.exit(1) zanatacmd = ZanataCommand() zanatacmd.pull_command(zanata, locale_map, project_id, iteration_id, filelist, lang_list, outpath, command_type) command_handler_factories = { 'help': makeHandler(help_info), 'list': makeHandler(list_project), 'project_info': makeHandler(project_info), 'project_create': makeHandler(create_project), 'version_info': makeHandler(version_info), 'version_create': makeHandler(create_version), 'po_pull': makeHandler(po_pull), 'po_push': makeHandler(po_push), 'publican_pull': makeHandler(publican_pull), 'publican_push': makeHandler(publican_push), 'push': makeHandler(push), 'pull': makeHandler(pull)