def cmd_pull(argv, path_to_tx): "Pull files from remote server to local repository" parser = pull_parser() (options, args) = parser.parse_args(argv) if options.fetchall and options.languages: parser.error("You can't user a language filter along with the"\ " -a|--all option") languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) pseudo = options.pseudo skip = options.skip_errors minimum_perc = options.minimum_perc or None try: _go_to_dir(path_to_tx) except UnInitializedError as e: utils.logger.error(e) return # instantiate the project.Project prj = project.Project(path_to_tx) prj.pull( languages=languages, resources=resources, overwrite=options.overwrite, fetchall=options.fetchall, fetchsource=options.fetchsource, force=options.force, skip=skip, minimum_perc=minimum_perc, mode=options.mode, pseudo=pseudo ) logger.info("Done.")
def cmd_pull(argv, path_to_tx): """Pull files from remote server to local repository""" parser = pull_parser() options = parser.parse_args(argv) if options.fetchall and options.languages: parser.error("You can't user a language filter along with the " "-a|--all option") languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) pseudo = options.pseudo # Should we download as xliff? xliff = options.xliff parallel = options.parallel skip = options.skip_errors minimum_perc = options.minimum_perc or None _go_to_dir(path_to_tx) # instantiate the project.Project prj = project.Project(path_to_tx) branch = get_branch_from_options(options, prj.root) prj.pull( languages=languages, resources=resources, overwrite=options.overwrite, fetchall=options.fetchall, fetchsource=options.fetchsource, force=options.force, skip=skip, minimum_perc=minimum_perc, mode=options.mode, pseudo=pseudo, xliff=xliff, branch=branch, parallel=parallel, no_interactive=options.no_interactive, ) logger.info("Done.")
def cmd_pull(argv, path_to_tx): """Pull files from remote server to local repository""" parser = pull_parser() (options, args) = parser.parse_args(argv) if options.fetchall and options.languages: parser.error("You can't user a language filter along with the " "-a|--all option") languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) pseudo = options.pseudo skip = options.skip_errors minimum_perc = options.minimum_perc or None try: _go_to_dir(path_to_tx) except UnInitializedError as e: utils.logger.error(e) return # instantiate the project.Project prj = project.Project(path_to_tx) prj.pull(languages=languages, resources=resources, overwrite=options.overwrite, fetchall=options.fetchall, fetchsource=options.fetchsource, force=options.force, skip=skip, minimum_perc=minimum_perc, mode=options.mode, pseudo=pseudo) logger.info("Done.")
def cmd_push(argv, path_to_tx): """Push local files to remote server""" parser = push_parser() options = parser.parse_args(argv) force_creation = options.force_creation languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors xliff = options.xliff parallel = options.parallel prj = project.Project(path_to_tx) if not (options.push_source or options.push_translations): parser.error("You need to specify at least one of the -s|--source, " "-t|--translations flags with the push command.") branch = get_branch_from_options(options, prj.root) prj.push(force=force_creation, resources=resources, languages=languages, skip=skip, source=options.push_source, translations=options.push_translations, no_interactive=options.no_interactive, xliff=xliff, branch=branch, parallel=parallel) logger.info("Done.")
def cmd_delete(argv, path_to_tx): "Delete an accessible resource or translation in a remote server." parser = delete_parser() (options, args) = parser.parse_args(argv) languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors force = options.force_delete prj = project.Project(path_to_tx) prj.delete(resources, languages, skip, force) logger.info("Done.")
def cmd_delete(argv, path_to_tx): """Delete an accessible resource or translation in a remote server.""" parser = delete_parser() options = parser.parse_args(argv) languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors force = options.force_delete prj = project.Project(path_to_tx) prj.delete(resources, languages, skip, force) logger.info("Done.")
def cmd_status(argv, path_to_tx): "Print status of current project" parser = status_parser() (options, args) = parser.parse_args(argv) resources = parse_csv_option(options.resources) prj = project.Project(path_to_tx) resources = prj.get_chosen_resources(resources) resources_num = len(resources) for idx, res in enumerate(resources): p, r = res.split('.') logger.info("%s -> %s (%s of %s)" % (p, r, idx + 1, resources_num)) logger.info("Translation Files:") slang = prj.get_resource_option(res, 'source_lang') sfile = prj.get_resource_option(res, 'source_file') or "N/A" lang_map = prj.get_resource_lang_mapping(res) logger.info(" - %s: %s (%s)" % (utils.color_text(slang, "RED"), sfile, utils.color_text("source", "YELLOW"))) files = prj.get_resource_files(res) fkeys = files.keys() fkeys.sort() for lang in fkeys: local_lang = lang if lang in lang_map.values(): local_lang = lang_map.flip[lang] logger.info(" - %s: %s" % (utils.color_text(local_lang, "RED"), files[lang])) logger.info("")
def cmd_status(argv, path_to_tx): """Print status of current project""" parser = status_parser() options = parser.parse_args(argv) resources = parse_csv_option(options.resources) prj = project.Project(path_to_tx) resources = prj.get_chosen_resources(resources) resources_num = len(resources) for idx, res in enumerate(resources): p, r = res.split('.') print("%s -> %s (%s of %s)" % (p, r, idx + 1, resources_num)) print("Translation Files:") slang = prj.get_resource_option(res, 'source_lang') sfile = prj.get_resource_option(res, 'source_file') or "N/A" lang_map = prj.get_resource_lang_mapping(res) print(" - %s: %s (%s)" % (utils.color_text(slang, "RED"), sfile, utils.color_text("source", "YELLOW"))) files = prj.get_resource_files(res) fkeys = list(files.keys()) fkeys.sort() for lang in fkeys: local_lang = lang if lang in list(lang_map.values()): local_lang = lang_map.flip[lang] print(" - %s: %s" % (utils.color_text(local_lang, "RED"), files[lang])) print("")
def cmd_pull(argv, path_to_tx): "Pull files from remote server to local repository" parser = pull_parser() (options, args) = parser.parse_args(argv) if options.fetchall and options.languages: parser.error("You can't user a language filter along with the"\ " -a|--all option") languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors minimum_perc = options.minimum_perc or None try: _go_to_dir(path_to_tx) except UnInitializedError, e: utils.logger.error(e) return
def cmd_pull(argv, path_to_tx): "Pull files from remote server to local repository" parser = pull_parser() (options, args) = parser.parse_args(argv) if options.fetchall and options.languages: parser.error("You can't user a language filter along with the"\ " -a|--all option") languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors minimum_perc = options.minimum_perc or None try: _go_to_dir(path_to_tx) except UnInitializedError, e: utils.logger.error(e) return
def cmd_push(argv, path_to_tx): "Push local files to remote server" parser = push_parser() (options, args) = parser.parse_args(argv) force_creation = options.force_creation languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors prj = project.Project(path_to_tx) if not (options.push_source or options.push_translations): parser.error("You need to specify at least one of the -s|--source," " -t|--translations flags with the push command.") prj.push( force=force_creation, resources=resources, languages=languages, skip=skip, source=options.push_source, translations=options.push_translations, no_interactive=options.no_interactive ) logger.info("Done.")
def cmd_push(argv, path_to_tx): "Push local files to remote server" parser = push_parser() (options, args) = parser.parse_args(argv) force_creation = options.force_creation languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors prj = project.Project(path_to_tx) if not (options.push_source or options.push_translations): parser.error("You need to specify at least one of the -s|--source," " -t|--translations flags with the push command.") prj.push( force=force_creation, resources=resources, languages=languages, skip=skip, source=options.push_source, num=options.num, translations=options.push_translations, no_interactive=options.no_interactive ) logger.info("Done.")
def cmd_push(argv, path_to_tx): """Push local files to remote server""" parser = push_parser() options = parser.parse_args(argv) force_creation = options.force_creation languages = parse_csv_option(options.languages) resources = parse_csv_option(options.resources) skip = options.skip_errors xliff = options.xliff parallel = options.parallel prj = project.Project(path_to_tx) if not (options.push_source or options.push_translations): parser.error("You need to specify at least one of the -s|--source, " "-t|--translations flags with the push command.") branch = get_branch_from_options(options, prj.root) prj.push( force=force_creation, resources=resources, languages=languages, skip=skip, source=options.push_source, translations=options.push_translations, no_interactive=options.no_interactive, xliff=xliff, branch=branch, parallel=parallel ) logger.info("Done.")