def subaward_types_are_valid_groups(type_list): """Check to ensure the award type list is a subset of one and only one award group. Groups: are "Procurement" and "Assistance" If false, the award type codes aren't a subset of either category. """ is_procurement = set(type_list).difference(set(procurement_type_mapping.keys())) is_assistance = set(type_list).difference(set(assistance_type_mapping.keys())) return bool(is_procurement) != bool(is_assistance) # clever XOR logic
from usaspending_api.awards.v2.lookups.lookups import procurement_type_mapping, assistance_type_mapping from usaspending_api.common.helpers.dict_helpers import order_nested_object from usaspending_api.common.helpers.generic_helper import generate_fiscal_year from usaspending_api.common.sqs.sqs_handler import get_sqs_queue from usaspending_api.download.filestreaming import download_generation from usaspending_api.download.helpers import multipart_upload, pull_modified_agencies_cgacs from usaspending_api.download.lookups import JOB_STATUS_DICT from usaspending_api.download.models import DownloadJob from usaspending_api.download.v2.request_validations import validate_award_request from usaspending_api.download.v2.year_limited_downloads import YearLimitedDownloadViewSet from usaspending_api.references.models import ToptierAgency logger = logging.getLogger(__name__) award_mappings = { "contracts": list(procurement_type_mapping.keys()), "assistance": list(assistance_type_mapping.keys()), } class Command(BaseCommand): def download( self, file_name, prime_award_types=None, agency=None, sub_agency=None, date_type=None, start_date=None, end_date=None, columns=[],