From f5f988a3a8beca835003af8d1680b2ef242b98cf Mon Sep 17 00:00:00 2001 From: kthoden Date: Mon, 28 Jun 2021 15:13:47 +0200 Subject: [PATCH] Add bibtex file to texfiles --- src/utils/load_config.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils/load_config.py b/src/utils/load_config.py index b615755..85b021c 100644 --- a/src/utils/load_config.py +++ b/src/utils/load_config.py @@ -11,10 +11,15 @@ import shlex import time import shutil -import glob import tempfile +def get_files(directory, extensions): + all_files = [] + for ext in extensions: + all_files.extend(Path(directory).glob(ext)) + return all_files + def copy_file_overwrite( src, dst ): if os.path.exists( dst ): shutil.rmtree( dst ) @@ -26,12 +31,15 @@ def copy_dir_overwrite( src, dst ): shutil.copytree( src, dst) def copy_dir_keepaux(src, dst): + src_files = get_files(src, ('*.tex', '*.bib')) + dst_files = get_files(dst, ('*.tex', '*.bib')) + if os.path.exists( dst ): - for filename in glob.glob(os.path.join(dst, '*.tex')): + for filename in dst_files: os.unlink(filename) else: os.mkdir(dst) - for filename in glob.glob(os.path.join(src, '*.tex')): + for filename in src_files: shutil.copy(filename, dst)