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 06dadc7..15a3b35 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..1db3b6e 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,8 +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_file_name = f"{self.code_name}_efiction_original_edited.sql" + self.edited_db_name = f"{prep_db_name(self.code_name)}_efiction_original" @staticmethod def _contains_table_defs(grouped_statements): @@ -120,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, 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 f82c502..c667e46 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,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"{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 3bc878c..48e43f8 100644 --- a/opendoors/utils.py +++ b/opendoors/utils.py @@ -21,6 +21,11 @@ def get_full_path(path): 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): """ Copy the source file to the destination path and filename