Improve clean method

This commit is contained in:
Benjamin Bertrand 2017-04-17 08:26:32 +03:00
parent 03d660df25
commit 232d6ac256
1 changed files with 9 additions and 10 deletions

View File

@ -89,17 +89,16 @@ def pdflatex(latex_file, output_dir=""):
logger.debug(f"{latex_file} has been compiled in {output_dir}")
def clean(dirname="."):
def clean(dirname=".", garbages=["*.aux", "*.log"]):
""" Clean the directory from aux and log latex files """
cleanning = subprocess.Popen(
[f"rm {dirname}/*.aux {dirname}/*.log"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True
)
out, err = cleanning.communicate()
logger.error(err)
logger.info(out)
if not dirname:
dirname = Path("./")
for g in garbages:
g_files = Path(dirname).files(g)
logger.debug(f"Remove {g_files}")
print(g_files)
for g_file in g_files:
g_file.remove()
# -----------------------------
# Reglages pour 'vim'