From 2630b25c7c089d98f2c4009bc928e0d830c509d5 Mon Sep 17 00:00:00 2001 From: axif Date: Tue, 3 Sep 2024 02:07:47 +0600 Subject: [PATCH 1/2] minor redundant code fix --- src/scribe_data/cli/cli_utils.py | 2 ++ src/scribe_data/cli/list.py | 17 +++-------------- src/scribe_data/load/data_to_sqlite.py | 1 - 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/scribe_data/cli/cli_utils.py b/src/scribe_data/cli/cli_utils.py index 510940277..fa446cbb5 100644 --- a/src/scribe_data/cli/cli_utils.py +++ b/src/scribe_data/cli/cli_utils.py @@ -26,6 +26,8 @@ from scribe_data.utils import DEFAULT_JSON_EXPORT_DIR +LANGUAGE_DATA_EXTRACTION_DIR = Path(__file__).parent.parent / "language_data_extraction" + LANGUAGE_METADATA_FILE = ( Path(__file__).parent.parent / "resources" / "language_metadata.json" ) diff --git a/src/scribe_data/cli/list.py b/src/scribe_data/cli/list.py index 349dc5824..6a34f8308 100644 --- a/src/scribe_data/cli/list.py +++ b/src/scribe_data/cli/list.py @@ -20,21 +20,10 @@ --> """ -import json -from pathlib import Path - from scribe_data.cli.cli_utils import correct_data_type - -# Load language metadata from JSON file. -METADATA_FILE = Path(__file__).parent.parent / "resources" / "language_metadata.json" -LANGUAGE_DATA_EXTRACTION_DIR = Path(__file__).parent.parent / "language_data_extraction" - -with METADATA_FILE.open("r", encoding="utf-8") as file: - language_metadata = json.load(file) - -language_map = { - lang["language"].lower(): lang for lang in language_metadata["languages"] -} +from scribe_data.utils import language_metadata +from scribe_data.utils import language_map +from scribe_data.utils import LANGUAGE_DATA_EXTRACTION_DIR def list_languages() -> None: diff --git a/src/scribe_data/load/data_to_sqlite.py b/src/scribe_data/load/data_to_sqlite.py index cbf82da36..644ba2e93 100644 --- a/src/scribe_data/load/data_to_sqlite.py +++ b/src/scribe_data/load/data_to_sqlite.py @@ -328,7 +328,6 @@ def table_insert(data_type, keys): ) print("Database creation/update process completed.") - print("Database creation/update process completed.") if __name__ == "__main__": From 5e81de1fb6e9a76bb2a0d27c8e7cb135bc56b53f Mon Sep 17 00:00:00 2001 From: axif Date: Tue, 3 Sep 2024 02:46:04 +0600 Subject: [PATCH 2/2] test error fix. --- src/scribe_data/cli/list.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scribe_data/cli/list.py b/src/scribe_data/cli/list.py index 6a34f8308..5d16b4413 100644 --- a/src/scribe_data/cli/list.py +++ b/src/scribe_data/cli/list.py @@ -20,10 +20,12 @@ --> """ -from scribe_data.cli.cli_utils import correct_data_type -from scribe_data.utils import language_metadata -from scribe_data.utils import language_map -from scribe_data.utils import LANGUAGE_DATA_EXTRACTION_DIR +from scribe_data.cli.cli_utils import ( + correct_data_type, + language_metadata, + language_map, + LANGUAGE_DATA_EXTRACTION_DIR, +) def list_languages() -> None: