From e7b69dc5d06ac6a34ba27ccd27c306081a1aff09 Mon Sep 17 00:00:00 2001 From: Sedalia Mae Date: Sun, 6 Sep 2026 14:50:02 -0400 Subject: [PATCH 1/5] made some changes to database naming --- efiction/metadata.py | 4 +++- efiction/original.py | 8 ++++++-- efiction/simplified.py | 4 ++-- opendoors/mysql.py | 5 ++++- opendoors/utils.py | 4 ++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/efiction/metadata.py b/efiction/metadata.py index 06dadc7..2d8b4c0 100644 --- a/efiction/metadata.py +++ b/efiction/metadata.py @@ -19,6 +19,7 @@ key_find, normalize, print_progress, + prep_db_name ) @@ -59,9 +60,10 @@ def create_open_doors_db(self, step_path): :return: True if successful """ od_table_sql_file = get_full_path("opendoors/open-doors-tables-working.sql") + self.config["Processing"][ "open_doors_working_db" - ] = f"{self.config['Archive']['code_name']}_working_open_doors" + ] = f"{prep_db_name(self.config['Archive']['code_name'])}_working_open_doors" self.config["Processing"]["open_doors_working_db_file"] = get_prefixed_path( "03", step_path, f"{self.config['Processing']['open_doors_working_db']}.sql" ) diff --git a/efiction/original.py b/efiction/original.py index 499db31..92ddb19 100644 --- a/efiction/original.py +++ b/efiction/original.py @@ -17,6 +17,7 @@ copy_to_dir, get_full_path, get_prefixed_path, + prep_db_name ) @@ -31,7 +32,7 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): self.config = config self.logger = logger self.code_name = config["Archive"]["code_name"] - self.edited_db_name = f"{self.code_name}_efiction_original" + self.edited_db_name = f"{prep_db_name(self.code_name)}_efiction_original" self.edited_file_name = f"{self.code_name}_efiction_original_edited.sql" @staticmethod @@ -129,7 +130,10 @@ def __load_into_database(self, step_path, statements): self.logger.info( "...removing any existing edited original database in MySQL..." ) - self.sql.drop_database(self.edited_db_name) + try: + self.sql.drop_database(self.edited_db_name) + except Exception as e: + self.logger.info(f"error with database drop at line 132: {e}. continuing") self.logger.info("...loading edited original database into MySQL...") self.sql.load_sql_file_into_db(edited_file) diff --git a/efiction/simplified.py b/efiction/simplified.py index f82c502..ace74b1 100644 --- a/efiction/simplified.py +++ b/efiction/simplified.py @@ -9,7 +9,7 @@ parse_remove_comments, write_statements_to_file, ) -from opendoors.utils import get_full_path, get_prefixed_path +from opendoors.utils import get_full_path, get_prefixed_path, prep_db_name class EFictionSimplified: @@ -40,7 +40,7 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): self.config = config self.logger = logger self.code_name = config["Archive"]["code_name"] - self.simplified_db_name = f"{self.code_name}_efiction_original_simplified" + self.simplified_db_name = f"{prep_db_name(self.code_name)}_efiction_original_simplified" self.simplified_file_name = f"{self.code_name}_efiction_original_simplified.sql" def __is_table_to_keep(self, table_name: str): diff --git a/opendoors/mysql.py b/opendoors/mysql.py index 43eefe5..b8f7832 100644 --- a/opendoors/mysql.py +++ b/opendoors/mysql.py @@ -119,7 +119,10 @@ def execute(self, database: str, statement: str, params: Tuple = None): def drop_database(self, database: str): cursor = self.conn.cursor() - cursor.execute(f"DROP DATABASE IF EXISTS {database};") + try: + cursor.execute(f"DROP DATABASE IF EXISTS {database};") + except Exception as e: + print(f"could not drop database: {e}") self.conn.commit() def dump_database(self, database: str, destination_filepath: str): diff --git a/opendoors/utils.py b/opendoors/utils.py index 3bc878c..779588c 100644 --- a/opendoors/utils.py +++ b/opendoors/utils.py @@ -20,6 +20,10 @@ def get_full_path(path): full_path: Path = Path(path).resolve(strict=False) return str(full_path) +def prep_db_name(config_name): + config_split = str(config_name).split("/") + return config_split[-1] + def copy_to_dir(old_file_path, new_file_dir, new_file_name): """ From 740d3e0d401483df4cd2c18ca3470215daf286b0 Mon Sep 17 00:00:00 2001 From: Sedalia Mae Date: Sun, 6 Sep 2026 18:07:48 -0400 Subject: [PATCH 2/5] cleaned up some triage and testing lines i'd added --- efiction/original.py | 5 +---- opendoors/mysql.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/efiction/original.py b/efiction/original.py index 92ddb19..5a5b16c 100644 --- a/efiction/original.py +++ b/efiction/original.py @@ -130,10 +130,7 @@ def __load_into_database(self, step_path, statements): self.logger.info( "...removing any existing edited original database in MySQL..." ) - try: - self.sql.drop_database(self.edited_db_name) - except Exception as e: - self.logger.info(f"error with database drop at line 132: {e}. continuing") + self.sql.drop_database(self.edited_db_name) self.logger.info("...loading edited original database into MySQL...") self.sql.load_sql_file_into_db(edited_file) diff --git a/opendoors/mysql.py b/opendoors/mysql.py index b8f7832..43eefe5 100644 --- a/opendoors/mysql.py +++ b/opendoors/mysql.py @@ -119,10 +119,7 @@ def execute(self, database: str, statement: str, params: Tuple = None): def drop_database(self, database: str): cursor = self.conn.cursor() - try: - cursor.execute(f"DROP DATABASE IF EXISTS {database};") - except Exception as e: - print(f"could not drop database: {e}") + cursor.execute(f"DROP DATABASE IF EXISTS {database};") self.conn.commit() def dump_database(self, database: str, destination_filepath: str): From 4d8632cdd051884411b3ace1b03fbd90fb0fd74e Mon Sep 17 00:00:00 2001 From: gingermae Date: Sun, 6 Sep 2026 18:34:15 -0400 Subject: [PATCH 3/5] made formatting changes after failed ruff test --- README.md | 4 ++-- efiction/metadata.py | 2 +- efiction/original.py | 2 +- efiction/simplified.py | 4 +++- opendoors/utils.py | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c03db8..3e5237a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ For example, if the archive is called "My Awesome Archive of Fandom Awesomeness" ``` 1. Run ```bash - python start.py CODENAME PATH-TO-WORKING-DIRECTORY + python3 start.py CODENAME PATH-TO-WORKING-DIRECTORY ``` where: @@ -40,7 +40,7 @@ Note that the process will create databases and tables in MySQL as well as files 1. Run ```bash - python start.py CODENAME PATH-TO-WORKING-DIRECTORY + python3 start.py CODENAME PATH-TO-WORKING-DIRECTORY ``` where: diff --git a/efiction/metadata.py b/efiction/metadata.py index 2d8b4c0..15a3b35 100644 --- a/efiction/metadata.py +++ b/efiction/metadata.py @@ -19,7 +19,7 @@ key_find, normalize, print_progress, - prep_db_name + prep_db_name, ) diff --git a/efiction/original.py b/efiction/original.py index 5a5b16c..4611a75 100644 --- a/efiction/original.py +++ b/efiction/original.py @@ -17,7 +17,7 @@ copy_to_dir, get_full_path, get_prefixed_path, - prep_db_name + prep_db_name, ) diff --git a/efiction/simplified.py b/efiction/simplified.py index ace74b1..c667e46 100644 --- a/efiction/simplified.py +++ b/efiction/simplified.py @@ -40,7 +40,9 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): self.config = config self.logger = logger self.code_name = config["Archive"]["code_name"] - self.simplified_db_name = f"{prep_db_name(self.code_name)}_efiction_original_simplified" + self.simplified_db_name = ( + f"{prep_db_name(self.code_name)}_efiction_original_simplified" + ) self.simplified_file_name = f"{self.code_name}_efiction_original_simplified.sql" def __is_table_to_keep(self, table_name: str): diff --git a/opendoors/utils.py b/opendoors/utils.py index 779588c..48e43f8 100644 --- a/opendoors/utils.py +++ b/opendoors/utils.py @@ -20,6 +20,7 @@ def get_full_path(path): full_path: Path = Path(path).resolve(strict=False) return str(full_path) + def prep_db_name(config_name): config_split = str(config_name).split("/") return config_split[-1] From e1a2f8e24b212d1bc918b8c2976d0fe45939411e Mon Sep 17 00:00:00 2001 From: Sedalia Mae Date: Sun, 6 Sep 2026 19:50:07 -0400 Subject: [PATCH 4/5] removed unnecessary init lines in original and simplified --- efiction/original.py | 4 ++-- efiction/simplified.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/efiction/original.py b/efiction/original.py index 4611a75..8e9adba 100644 --- a/efiction/original.py +++ b/efiction/original.py @@ -33,7 +33,7 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): self.logger = logger self.code_name = config["Archive"]["code_name"] self.edited_db_name = f"{prep_db_name(self.code_name)}_efiction_original" - self.edited_file_name = f"{self.code_name}_efiction_original_edited.sql" + #self.edited_file_name = f"{self.code_name}_efiction_original_edited.sql" @staticmethod def _contains_table_defs(grouped_statements): @@ -121,7 +121,7 @@ def __load_into_database(self, step_path, statements): :return: """ self.logger.info("...writing edited SQL statements to a backup file...") - edited_file_path = get_prefixed_path("01", step_path, self.edited_file_name) + edited_file_path = get_prefixed_path("01", step_path, f"{self.edited_db_name}.sql") self.config["Processing"]["original_edited_file"] = edited_file_path edited_file = write_statements_to_file( self.config["Processing"]["original_edited_file"], statements diff --git a/efiction/simplified.py b/efiction/simplified.py index c667e46..41d7192 100644 --- a/efiction/simplified.py +++ b/efiction/simplified.py @@ -44,6 +44,7 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): f"{prep_db_name(self.code_name)}_efiction_original_simplified" ) self.simplified_file_name = f"{self.code_name}_efiction_original_simplified.sql" + self.simplified_db_name = f"{prep_db_name(self.code_name)}_efiction_original_simplified" def __is_table_to_keep(self, table_name: str): """ From cf496681165604dfc50e1310f8e26dc507aee984 Mon Sep 17 00:00:00 2001 From: gingermae Date: Sun, 6 Sep 2026 19:57:51 -0400 Subject: [PATCH 5/5] fixed from linting checks --- efiction/original.py | 5 +++-- efiction/simplified.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/efiction/original.py b/efiction/original.py index 8e9adba..1db3b6e 100644 --- a/efiction/original.py +++ b/efiction/original.py @@ -33,7 +33,6 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): self.logger = logger self.code_name = config["Archive"]["code_name"] self.edited_db_name = f"{prep_db_name(self.code_name)}_efiction_original" - #self.edited_file_name = f"{self.code_name}_efiction_original_edited.sql" @staticmethod def _contains_table_defs(grouped_statements): @@ -121,7 +120,9 @@ def __load_into_database(self, step_path, statements): :return: """ self.logger.info("...writing edited SQL statements to a backup file...") - edited_file_path = get_prefixed_path("01", step_path, f"{self.edited_db_name}.sql") + edited_file_path = get_prefixed_path( + "01", step_path, f"{self.edited_db_name}.sql" + ) self.config["Processing"]["original_edited_file"] = edited_file_path edited_file = write_statements_to_file( self.config["Processing"]["original_edited_file"], statements diff --git a/efiction/simplified.py b/efiction/simplified.py index 41d7192..c667e46 100644 --- a/efiction/simplified.py +++ b/efiction/simplified.py @@ -44,7 +44,6 @@ def __init__(self, config: ConfigParser, logger: Logger, sql: SqlDb): f"{prep_db_name(self.code_name)}_efiction_original_simplified" ) self.simplified_file_name = f"{self.code_name}_efiction_original_simplified.sql" - self.simplified_db_name = f"{prep_db_name(self.code_name)}_efiction_original_simplified" def __is_table_to_keep(self, table_name: str): """