From cb9b135178306af629791e7d422c0d32b8a023e9 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Tue, 7 Nov 2023 15:19:23 -0600 Subject: [PATCH] Updated hand-off for JSON parsing --- .../commands/load_transition_domain.py | 36 +++++++++++++------ .../commands/master_domain_migrations.py | 20 +++++------ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/registrar/management/commands/load_transition_domain.py b/src/registrar/management/commands/load_transition_domain.py index d08b1c2ed..9496789f1 100644 --- a/src/registrar/management/commands/load_transition_domain.py +++ b/src/registrar/management/commands/load_transition_domain.py @@ -41,14 +41,11 @@ class Command(BaseCommand): for testing purposes, but USE WITH CAUTION """ parser.add_argument( - "domain_contacts_filename", help="Data file with domain contact information" - ) - parser.add_argument( - "contacts_filename", - help="Data file with contact information", - ) - parser.add_argument( - "domain_statuses_filename", help="Data file with domain status information" + "migration_Json_filename", + help=( + "A JSON file that holds the location and filenames" + "of all the data files used for migrations" + ), ) parser.add_argument("--sep", default="|", help="Delimiter character") @@ -71,6 +68,19 @@ class Command(BaseCommand): parser.add_argument( "--directory", default="migrationdata", help="Desired directory" ) + + parser.add_argument( + "--domain_contacts_filename", + help="Data file with domain contact information" + ) + parser.add_argument( + "--contacts_filename", + help="Data file with contact information", + ) + parser.add_argument( + "--domain_statuses_filename", + help="Data file with domain status information" + ) parser.add_argument( "--infer_filenames", action=argparse.BooleanOptionalAction, @@ -309,9 +319,7 @@ class Command(BaseCommand): def handle( # noqa: C901 self, - domain_contacts_filename, - contacts_filename, - domain_statuses_filename, + migration_Json_filename, **options, ): """Parse the data files and create TransitionDomains.""" @@ -336,6 +344,12 @@ class Command(BaseCommand): # (In the event they are stored seperately) directory = options.get("directory") + # Main script filenames + # TODO: @ZANDER to replace this with new TransitionDomainArgument object + domain_contacts_filename = directory+ options.get("domain_contacts_filename") + contacts_filename = directory+ options.get("contacts_filename") + domain_statuses_filename = directory+ options.get("domain_statuses_filename") + # Agency information agency_adhoc_filename = options.get("agency_adhoc_filename") # Federal agency / organization type information diff --git a/src/registrar/management/commands/master_domain_migrations.py b/src/registrar/management/commands/master_domain_migrations.py index 3019ac8ef..673345b8a 100644 --- a/src/registrar/management/commands/master_domain_migrations.py +++ b/src/registrar/management/commands/master_domain_migrations.py @@ -99,7 +99,7 @@ class Command(BaseCommand): # TODO: make this a mandatory argument (if/when we strip out defaults, it will be mandatory) # TODO: use the migration directory arg or force user to type FULL filepath? parser.add_argument( - "migrationJson", + "migration_Json_filename", help=( "A JSON file that holds the location and filenames" "of all the data files used for migrations" @@ -281,7 +281,7 @@ class Command(BaseCommand): # ====================================================== def run_load_transition_domain_script( self, - migrationJson: str, + migration_Json_filename: str, file_location: str, domain_contacts_filename: str, contacts_filename: str, @@ -297,9 +297,7 @@ class Command(BaseCommand): command_script = "load_transition_domain" command_string = ( f"./manage.py {command_script} " - f"{file_location+domain_contacts_filename} " - f"{file_location+contacts_filename} " - f"{file_location+domain_statuses_filename} " + f"{file_location+migration_Json_filename}" ) if sep is not None and sep != "|": command_string += f"--sep {sep} " @@ -323,9 +321,7 @@ class Command(BaseCommand): if proceed: call_command( command_script, - f"{file_location+domain_contacts_filename}", - f"{file_location+contacts_filename}", - f"{file_location+domain_statuses_filename}", + f"{file_location+migration_Json_filename}", sep=sep, resetTable=reset_table, debug=debug_on, @@ -372,7 +368,7 @@ class Command(BaseCommand): def run_migration_scripts( self, - migrationJson, + migration_Json_filename, file_location, domain_contacts_filename, contacts_filename, @@ -424,7 +420,7 @@ class Command(BaseCommand): # Proceed executing the migration scripts self.run_load_transition_domain_script( - migrationJson, + migration_Json_filename, file_location, domain_contacts_filename, contacts_filename, @@ -439,7 +435,7 @@ class Command(BaseCommand): def handle( self, - migrationJson, + migration_Json_filename, **options, ): """ @@ -534,7 +530,7 @@ class Command(BaseCommand): # Run migration scripts self.run_migration_scripts( - migrationJson, + migration_Json_filename, file_location, domain_contacts_filename, contacts_filename,