Download render/__init__.py from p1utoze/hAIring: direct link, hf CLI and curl.
- Browser
- Download file 744 Bytes
-
https://huggingface.co/spaces/p1utoze/hAIring/resolve/main/render/__init__.py
- Command line
-
hf download hf://spaces/p1utoze/hAIring/render/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/p1utoze/hAIring/resolve/main/render/__init__.py
744 Bytes
| import tempfile | |
| import subprocess | |
| import os | |
| import shutil | |
| def render_latex(latex_command, latex_data): | |
| src_path = os.path.dirname(os.path.realpath(__file__)) + "/inputs" | |
| with tempfile.TemporaryDirectory() as tmpdirname: | |
| # Copy auxiliary files to temporary directory | |
| shutil.copytree(src_path, tmpdirname, dirs_exist_ok=True) | |
| # write latex data to a file | |
| with open(f"{tmpdirname}/resume.tex", "w") as f: | |
| f.write(latex_data) | |
| # run latex command | |
| latex_process = subprocess.Popen(latex_command, cwd=tmpdirname) | |
| latex_process.wait() | |
| # read pdf data | |
| with open(f"{tmpdirname}/resume.pdf", "rb") as f: | |
| pdf_data = f.read() | |
| return pdf_data | |