Updated hand-off for JSON parsing

This commit is contained in:
CocoByte 2023-11-07 15:19:23 -06:00
parent bf374725cb
commit cb9b135178
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
2 changed files with 33 additions and 23 deletions

View file

@ -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

View file

@ -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,