Solve feed bugs
This commit is contained in:
parent
710928869d
commit
62b35274e9
@ -42,20 +42,22 @@ def feed(template, data, output="", force=0):
|
||||
|
||||
if not output:
|
||||
num = 1
|
||||
output_p = Path(template).replace('tpl', f'{num:02d}')
|
||||
while output.exists() or not force:
|
||||
output_p = Path(template.replace('tpl', f'{num:02d}'))
|
||||
while output_p.exists() and not force:
|
||||
logger.debug(f"{output_p} exists. Try next one")
|
||||
num += 1
|
||||
output_p = Path(template).replace('tpl', f'{num:02d}')
|
||||
elif not force:
|
||||
logger.error(f"{output} exists. Use force=1 do override it")
|
||||
raise ValueError(f"{output} exists. Use force=1 do override it")
|
||||
output_p = Path(template.replace('tpl', f'{num:02d}'))
|
||||
else:
|
||||
output_p = Path(output)
|
||||
if not force and output_p.exists():
|
||||
logger.error(f"{output} exists. Use force=1 do override it")
|
||||
raise ValueError(f"{output} exists. Use force=1 do override it")
|
||||
|
||||
output_dir = output_p.dirname()
|
||||
if not output_dir.exists():
|
||||
output_dir.mkdir()
|
||||
if output_dir and not output_dir.exists():
|
||||
output_dir.mkdir_p()
|
||||
|
||||
with open(output, "w") as output_f:
|
||||
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}.")
|
||||
|
||||
@ -87,7 +89,7 @@ def pdflatex(latex_file, output_dir=""):
|
||||
logger.debug(f"{latex_file} has been compiled in {output_dir}")
|
||||
|
||||
|
||||
def clean(dirname):
|
||||
def clean(dirname="."):
|
||||
""" Clean the directory from aux and log latex files """
|
||||
cleanning = subprocess.Popen(
|
||||
[f"rm {dirname}/*.aux {dirname}/*.log"],
|
||||
@ -99,9 +101,6 @@ def clean(dirname):
|
||||
logger.error(err)
|
||||
logger.info(out)
|
||||
|
||||
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue
Block a user