mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-31 09:43:54 +02:00
Updated hand-off for JSON parsing
This commit is contained in:
parent
bf374725cb
commit
cb9b135178
2 changed files with 33 additions and 23 deletions
|
@ -41,14 +41,11 @@ class Command(BaseCommand):
|
||||||
for testing purposes, but USE WITH CAUTION
|
for testing purposes, but USE WITH CAUTION
|
||||||
"""
|
"""
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"domain_contacts_filename", help="Data file with domain contact information"
|
"migration_Json_filename",
|
||||||
)
|
help=(
|
||||||
parser.add_argument(
|
"A JSON file that holds the location and filenames"
|
||||||
"contacts_filename",
|
"of all the data files used for migrations"
|
||||||
help="Data file with contact information",
|
),
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"domain_statuses_filename", help="Data file with domain status information"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument("--sep", default="|", help="Delimiter character")
|
parser.add_argument("--sep", default="|", help="Delimiter character")
|
||||||
|
@ -71,6 +68,19 @@ class Command(BaseCommand):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--directory", default="migrationdata", help="Desired directory"
|
"--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(
|
parser.add_argument(
|
||||||
"--infer_filenames",
|
"--infer_filenames",
|
||||||
action=argparse.BooleanOptionalAction,
|
action=argparse.BooleanOptionalAction,
|
||||||
|
@ -309,9 +319,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle( # noqa: C901
|
def handle( # noqa: C901
|
||||||
self,
|
self,
|
||||||
domain_contacts_filename,
|
migration_Json_filename,
|
||||||
contacts_filename,
|
|
||||||
domain_statuses_filename,
|
|
||||||
**options,
|
**options,
|
||||||
):
|
):
|
||||||
"""Parse the data files and create TransitionDomains."""
|
"""Parse the data files and create TransitionDomains."""
|
||||||
|
@ -336,6 +344,12 @@ class Command(BaseCommand):
|
||||||
# (In the event they are stored seperately)
|
# (In the event they are stored seperately)
|
||||||
directory = options.get("directory")
|
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 information
|
||||||
agency_adhoc_filename = options.get("agency_adhoc_filename")
|
agency_adhoc_filename = options.get("agency_adhoc_filename")
|
||||||
# Federal agency / organization type information
|
# Federal agency / organization type information
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Command(BaseCommand):
|
||||||
# TODO: make this a mandatory argument (if/when we strip out defaults, it will be mandatory)
|
# 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?
|
# TODO: use the migration directory arg or force user to type FULL filepath?
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"migrationJson",
|
"migration_Json_filename",
|
||||||
help=(
|
help=(
|
||||||
"A JSON file that holds the location and filenames"
|
"A JSON file that holds the location and filenames"
|
||||||
"of all the data files used for migrations"
|
"of all the data files used for migrations"
|
||||||
|
@ -281,7 +281,7 @@ class Command(BaseCommand):
|
||||||
# ======================================================
|
# ======================================================
|
||||||
def run_load_transition_domain_script(
|
def run_load_transition_domain_script(
|
||||||
self,
|
self,
|
||||||
migrationJson: str,
|
migration_Json_filename: str,
|
||||||
file_location: str,
|
file_location: str,
|
||||||
domain_contacts_filename: str,
|
domain_contacts_filename: str,
|
||||||
contacts_filename: str,
|
contacts_filename: str,
|
||||||
|
@ -297,9 +297,7 @@ class Command(BaseCommand):
|
||||||
command_script = "load_transition_domain"
|
command_script = "load_transition_domain"
|
||||||
command_string = (
|
command_string = (
|
||||||
f"./manage.py {command_script} "
|
f"./manage.py {command_script} "
|
||||||
f"{file_location+domain_contacts_filename} "
|
f"{file_location+migration_Json_filename}"
|
||||||
f"{file_location+contacts_filename} "
|
|
||||||
f"{file_location+domain_statuses_filename} "
|
|
||||||
)
|
)
|
||||||
if sep is not None and sep != "|":
|
if sep is not None and sep != "|":
|
||||||
command_string += f"--sep {sep} "
|
command_string += f"--sep {sep} "
|
||||||
|
@ -323,9 +321,7 @@ class Command(BaseCommand):
|
||||||
if proceed:
|
if proceed:
|
||||||
call_command(
|
call_command(
|
||||||
command_script,
|
command_script,
|
||||||
f"{file_location+domain_contacts_filename}",
|
f"{file_location+migration_Json_filename}",
|
||||||
f"{file_location+contacts_filename}",
|
|
||||||
f"{file_location+domain_statuses_filename}",
|
|
||||||
sep=sep,
|
sep=sep,
|
||||||
resetTable=reset_table,
|
resetTable=reset_table,
|
||||||
debug=debug_on,
|
debug=debug_on,
|
||||||
|
@ -372,7 +368,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def run_migration_scripts(
|
def run_migration_scripts(
|
||||||
self,
|
self,
|
||||||
migrationJson,
|
migration_Json_filename,
|
||||||
file_location,
|
file_location,
|
||||||
domain_contacts_filename,
|
domain_contacts_filename,
|
||||||
contacts_filename,
|
contacts_filename,
|
||||||
|
@ -424,7 +420,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Proceed executing the migration scripts
|
# Proceed executing the migration scripts
|
||||||
self.run_load_transition_domain_script(
|
self.run_load_transition_domain_script(
|
||||||
migrationJson,
|
migration_Json_filename,
|
||||||
file_location,
|
file_location,
|
||||||
domain_contacts_filename,
|
domain_contacts_filename,
|
||||||
contacts_filename,
|
contacts_filename,
|
||||||
|
@ -439,7 +435,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(
|
def handle(
|
||||||
self,
|
self,
|
||||||
migrationJson,
|
migration_Json_filename,
|
||||||
**options,
|
**options,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -534,7 +530,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Run migration scripts
|
# Run migration scripts
|
||||||
self.run_migration_scripts(
|
self.run_migration_scripts(
|
||||||
migrationJson,
|
migration_Json_filename,
|
||||||
file_location,
|
file_location,
|
||||||
domain_contacts_filename,
|
domain_contacts_filename,
|
||||||
contacts_filename,
|
contacts_filename,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue