def translate_(args, log_file, log_path): log = translate_log(log_file, args.fix_checksum) printer = Printer() if args.output_file: printer = PrinterFile(args.output_file) try: printer.print(format_translation(log_path, log, args.pure_translate)) except UnicodeEncodeError as error: printer.print('Cannot encode logpath: {}'.format(error))
def handle_file(action, file_): filename = get_filename() file_.save(filename) log_file = Path(filename) if action == 'Score': contents = score_log(log_file, markup=True) contents['contents'] = Markup(contents['contents']) return render_template('score.html', contents=contents) elif action == 'Translate': contents = translate_log(log_file) if 'log' in contents: contents['log'] = Markup(contents['log']) return render_template('translate.html', contents=contents)
def test_translation(filename): log_path = os.path.join(os.path.dirname(__file__), 'logs', 'translations', filename) log_file = Path(log_path) log = translate_log(log_file) translated_path = os.path.join( os.path.dirname(__file__), 'logs', 'translations', 'translated', '{}.translated'.format(filename), ) with open(translated_path, 'r') as translated_file: translated_contents = translated_file.read() assert log['log'] == translated_contents
def _check_log(path, score_only, translate): figle = Path(path) scored_log = score_log(figle, markup=False) if score_only: if scored_log["unrecognized"]: return click.secho("Unrecognized") return click.echo(scored_log["score"]) try: click.echo(format_score(path, scored_log, markup=False)) if translate: translated_log = translate_log(figle) click.secho( "\n---------------------------------------------------\n" + format_translation(path, translated_log)) except UnicodeEncodeError as e: click.secho(f"Could not encode logpath: {e}")
def translate_(args, log_file, log_path): log = translate_log(log_file) try: print(format_translation(log_path, log)) except UnicodeEncodeError as error: print('Cannot encode logpath: {}'.format(error))