def markdown_generation(_resume, _localizations, _output, _output_directory, _j2_env): _logger = logging.getLogger("Resume Convertor") for _locale in _localizations: _logger.info("Генерація markdown для " + _locale + " мови") generated_json = md.generate_localized_markdown(_resume, _locale) local_file = open(os.path.join(args.localization_directory, _locale + ".py")) localization_map = eval(util.read_full_file(local_file)) local_file.close() generated_json.update(localization_map) markdown_file = open(os.path.join(_output_directory, _output.replace("%", _locale) + '.md'), 'w') markdown_file.write(_j2_env.get_template('markdown.template').render(generated_json)) markdown_file.close()
def latex_generation(_resume, _localization, _output, _output_directory, _j2_env, _template_directory): _logger = logging.getLogger("Resume Convertor") for _locale in _localization: _logger.info("Генерація xelatex для " + _locale + " мови") generated_json = tex.generate_localized_latex(_resume, _locale) local_file = open(os.path.join(args.localization_directory, _locale + ".py")) localization_map = eval(util.read_full_file(local_file)) local_file.close() generated_json.update(localization_map) latex_file = open(os.path.join(_template_directory, "LatexInclude", "main.tex"), 'w') latex_file.write(_j2_env.get_template('latex.template').render(generated_json)) latex_file.close() latex_include = os.path.join(_template_directory, "LatexInclude") _logger.info("Компіляція xelatex файлу") subprocess.call(["xelatex", "main.tex"], cwd=latex_include, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) for file in ['main.aux', 'main.out', 'main.log', 'main.tex']: os.remove(os.path.join(latex_include, file)) os.rename(os.path.join(latex_include, 'main.pdf'), os.path.join(_output_directory, _output.replace('%', _locale) + '.pdf'))