paths cleaning
This commit is contained in:
parent
a3b8711fbf
commit
36d182c860
@ -1,7 +1,7 @@
|
||||
Pytex
|
||||
=====
|
||||
|
||||
Pytex is a simple package which make aa bridge between Latex and Python.
|
||||
Pytex is a simple package which make a bridge between Latex and Python.
|
||||
|
||||
texenv: Bring Python inside latex
|
||||
---------------------------------
|
||||
|
@ -38,6 +38,8 @@ def feed(template, data, output="", force=0):
|
||||
:param output: name of the output file
|
||||
(by default: tpl is replaced by a 2 digits number)
|
||||
:param force: Override is the output already exists
|
||||
|
||||
:return: name of fed template
|
||||
"""
|
||||
logger.info(f"Getting template {template}")
|
||||
tpl = texenv.get_template(str(template))
|
||||
@ -57,21 +59,23 @@ def feed(template, data, output="", force=0):
|
||||
|
||||
output_dir = output_p.dirname()
|
||||
if output_dir and not output_dir.exists():
|
||||
logger.debug(f"Creating output dir {output_dir}")
|
||||
output_dir.mkdir_p()
|
||||
|
||||
with open(output_p, "w") as output_f:
|
||||
output_f.write(tpl.render(**EXPORT_DICT, **data))
|
||||
logger.info(f"{template} has been rendered to {output}.")
|
||||
return output_p
|
||||
|
||||
|
||||
def pdflatex(latex_file, output_dir=""):
|
||||
""" Compile latex file
|
||||
""" Compile a latex file with pdflatex
|
||||
|
||||
If output_dir is not set, it produce it next to the latex file.
|
||||
"""
|
||||
if not output_dir:
|
||||
output_dir = Path(latex_file).dirname().abspath()
|
||||
logger.debug(f"output_dir for dflatex is {output_dir}")
|
||||
logger.debug(f"output_dir for pdflatex is {output_dir}")
|
||||
|
||||
pwd = Path('./').abspath()
|
||||
Path(output_dir).cd()
|
||||
@ -96,7 +100,7 @@ def pdflatex(latex_file, output_dir=""):
|
||||
pwd.cd()
|
||||
|
||||
|
||||
def clean(dirname=".", garbages=["*.aux", "*.log"]):
|
||||
def clean(dirname="", garbages=["*.aux", "*.log"]):
|
||||
""" Clean the directory from aux and log latex files """
|
||||
if not dirname:
|
||||
dirname = Path("./")
|
||||
|
Loading…
Reference in New Issue
Block a user