From fce23497e9f65cae03d185cad99d4ce836444a2a Mon Sep 17 00:00:00 2001 From: Leonardo Cavaletti Date: Wed, 27 May 2020 10:15:13 +0100 Subject: [PATCH] Changed --clean-style into --clean-css, added --clean-js --- loconotion/__main__.py | 9 +++++++-- loconotion/notionparser.py | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/loconotion/__main__.py b/loconotion/__main__.py index 2ce16f5..5b8a6ce 100644 --- a/loconotion/__main__.py +++ b/loconotion/__main__.py @@ -40,9 +40,14 @@ def main(): help="Delete all previously cached files for the site before generating it", ) argparser.add_argument( - "--clean-style", + "--clean-css", action="store_true", - help="Delete only previously cached .css files for the site before generating it", + help="Delete previously cached .css files for the site before generating it", + ) + argparser.add_argument( + "--clean-js", + action="store_true", + help="Delete previously cached .js files for the site before generating it", ) argparser.add_argument( "--non-headless", diff --git a/loconotion/notionparser.py b/loconotion/notionparser.py index f052a3c..78a1e7f 100644 --- a/loconotion/notionparser.py +++ b/loconotion/notionparser.py @@ -58,16 +58,24 @@ class Parser: if self.args.get("clean", False): try: shutil.rmtree(self.dist_folder) - log.info(f"Removing previously cached files in '{self.dist_folder}'") + log.info(f"Removing cached files in '{self.dist_folder}'") except OSError as e: log.error(f"Cannot remove '{self.dist_folder}': {e}") - elif self.args.get("clean_style", False): - try: - log.info(f"Removing previously cached style files in '{self.dist_folder}'") - for style_file in glob.glob(str(self.dist_folder / "*.css")): - os.remove(style_file) - except OSError as e: - log.error(f"Cannot remove syle files in '{self.dist_folder}': {e}") + else: + if self.args.get("clean_css", False): + try: + log.info(f"Removing cached .css files in '{self.dist_folder}'") + for style_file in glob.glob(str(self.dist_folder / "*.css")): + os.remove(style_file) + except OSError as e: + log.error(f"Cannot remove .css files in '{self.dist_folder}': {e}") + if self.args.get("clean_js", False): + try: + log.info(f"Removing cached .js files in '{self.dist_folder}'") + for style_file in glob.glob(str(self.dist_folder / "*.css")): + os.remove(style_file) + except OSError as e: + log.error(f"Cannot remove .js files in '{self.dist_folder}': {e}") # create the output folder if necessary self.dist_folder.mkdir(parents=True, exist_ok=True)