From 232d6ac256e0815efc86fc5790a257e1d87fc438 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Mon, 17 Apr 2017 08:26:32 +0300 Subject: [PATCH] Improve clean method --- pytex/pytex.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pytex/pytex.py b/pytex/pytex.py index c6b9984..8e327df 100644 --- a/pytex/pytex.py +++ b/pytex/pytex.py @@ -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'