From 578643e865ce69c68c38f60868d18178b5e973f8 Mon Sep 17 00:00:00 2001 From: Matt Garber Date: Tue, 24 Oct 2023 09:12:45 -0400 Subject: [PATCH] study parser cleanup --- cumulus_library/cli_parser.py | 6 +++--- cumulus_library/study_parser.py | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cumulus_library/cli_parser.py b/cumulus_library/cli_parser.py index e5f4bfd0..f25005aa 100644 --- a/cumulus_library/cli_parser.py +++ b/cumulus_library/cli_parser.py @@ -16,7 +16,7 @@ def add_table_builder_argument(parser: argparse.ArgumentParser) -> None: """Adds --builder arg to a subparser""" parser.add_argument( "--builder", - help=(argparse.SUPPRESS), + help=argparse.SUPPRESS, ) @@ -129,7 +129,7 @@ def get_parser() -> argparse.ArgumentParser: clean.add_argument( "--prefix", action="store_true", - help=(argparse.SUPPRESS), + help=argparse.SUPPRESS, ) build = actions.add_parser( @@ -145,7 +145,7 @@ def get_parser() -> argparse.ArgumentParser: build.add_argument( "--continue", dest="continue_from", - help=(argparse.SUPPRESS), + help=argparse.SUPPRESS, ) export = actions.add_parser( diff --git a/cumulus_library/study_parser.py b/cumulus_library/study_parser.py index 2a6a7361..6fab3e05 100644 --- a/cumulus_library/study_parser.py +++ b/cumulus_library/study_parser.py @@ -94,15 +94,11 @@ def get_sql_file_list(self, continue_from: str = None) -> Optional[StrList]: sql_config = self._study_config.get("sql_config", {}) sql_files = sql_config.get("file_names", []) if continue_from: - match_found = False - for file in sql_files: - print(continue_from.replace(".sql", "")) - print(file.replace(".sql", "")) + for pos, file in enumerate(sql_files): if continue_from.replace(".sql", "") == file.replace(".sql", ""): - sql_files = sql_files[sql_files.index(file) :] - match_found = True + sql_files = sql_files[pos:] break - if not match_found: + else: sys.exit(f"No tables matching '{continue_from}' found") return sql_files @@ -206,7 +202,7 @@ def clean_study( print("The following views/tables were selected by prefix:") for view_table in view_table_list: print(f" {view_table[0]}") - confirm = input("Remove these tables? (Y/N)") + confirm = input("Remove these tables? (y/N)") if confirm.lower() not in ("y", "yes"): sys.exit("Table cleaning aborted") with get_progress_bar(disable=verbose) as progress: