Revert "Lint part 2"

This reverts commit bf9824a109.
This commit is contained in:
zandercymatics 2025-01-09 15:03:30 -07:00
parent bf9824a109
commit 25cf2fe79f
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -61,22 +61,6 @@ class Command(BaseCommand):
parse_domains = options.get("parse_domains")
both = options.get("both")
# C901 'Command.handle' is too complex (12)
self.validate_parse_options(parse_requests, parse_domains, both)
agencies = self.get_agencies(agency_name, branch)
self.handle_all_populate_portfolio(agencies, parse_domains, parse_requests, both)
TerminalHelper.log_script_run_summary(
self.updated_portfolios,
self.failed_portfolios,
self.skipped_portfolios,
debug=False,
skipped_header="----- SOME PORTFOLIOS WERE SKIPPED -----",
display_as_str=True,
)
def validate_parse_options(self, parse_requests, parse_domains, both):
"""Validates parse options. Raises a CommandError if invalid."""
if not both:
if not parse_requests and not parse_domains:
raise CommandError("You must specify at least one of --parse_requests or --parse_domains.")
@ -84,12 +68,9 @@ class Command(BaseCommand):
if parse_requests or parse_domains:
raise CommandError("You cannot pass --parse_requests or --parse_domains when passing --both.")
def get_agencies(self, agency_name, branch):
"""Get federal agencies based on command options. Raises a CommandError if invalid."""
federal_agency_filter = {"agency__iexact": agency_name} if agency_name else {"federal_type": branch}
agencies = FederalAgency.objects.filter(**federal_agency_filter)
if not agencies.exists():
if not agencies or agencies.count() < 1:
if agency_name:
raise CommandError(
f"Cannot find the federal agency '{agency_name}' in our database. "
@ -99,7 +80,16 @@ class Command(BaseCommand):
else:
raise CommandError(f"Cannot find '{branch}' federal agencies in our database.")
return agencies
# C901 'Command.handle' is too complex (12)
self.handle_all_populate_portfolio(agencies, parse_domains, parse_requests, both)
TerminalHelper.log_script_run_summary(
self.updated_portfolios,
self.failed_portfolios,
self.skipped_portfolios,
debug=False,
skipped_header="----- SOME PORTFOLIOS WERE SKIPPED -----",
display_as_str=True,
)
def handle_all_populate_portfolio(self, agencies, parse_domains, parse_requests, both):
"""Loops through every agency and creates a portfolio for each.