def calculate_remaining_fields(obj, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, atom_type):
    " Calculate values that aren't in any feed but can be calculated.\n\n        Args:\n            obj: a dictionary containing the details we need to derive from and to\n            sess: the database connection\n            sub_tier_list: a dictionary containing all the sub tier agency information keyed by sub tier agency code\n            county_by_name: a dictionary containing all county codes, keyed by state and county name\n            county_by_code: a dictionary containing all county names, keyed by state and county code\n            state_code_list: a dictionary containing all state names, keyed by state code\n            country_list: a dictionary containing all country names, keyed by country code\n            exec_comp_dict: a dictionary containing all the data for Executive Compensation data keyed by DUNS number\n            atom_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'\n\n        Returns:\n            the object originally passed in with newly-calculated values added\n    "
    obj['awarding_agency_code'] = None
    obj['awarding_agency_name'] = None
    obj['funding_agency_code'] = None
    obj['funding_agency_name'] = None
    obj['place_of_perform_county_co'] = None
    obj['legal_entity_county_code'] = None
    obj['legal_entity_county_name'] = None
    obj['detached_award_proc_unique'] = None
    if obj['awarding_sub_tier_agency_c']:
        try:
            sub_tier_agency = sub_tier_list[obj['awarding_sub_tier_agency_c']]
            use_frec = sub_tier_agency.is_frec
            agency_data = (sub_tier_agency.frec if use_frec else sub_tier_agency.cgac)
            obj['awarding_agency_code'] = (agency_data.frec_code if use_frec else agency_data.cgac_code)
            obj['awarding_agency_name'] = agency_data.agency_name
        except KeyError:
            logger.info('WARNING: MissingSubtierCGAC: The awarding sub-tier cgac_code: %s does not exist in cgac table. The FPDS-provided awarding sub-tier agency name (if given) for this cgac_code is %s. The award has been loaded with awarding_agency_code 999.', obj['awarding_sub_tier_agency_c'], obj['awarding_sub_tier_agency_n'])
            obj['awarding_agency_code'] = '999'
            obj['awarding_agency_name'] = None
    if obj['funding_sub_tier_agency_co']:
        try:
            sub_tier_agency = sub_tier_list[obj['funding_sub_tier_agency_co']]
            use_frec = sub_tier_agency.is_frec
            agency_data = (sub_tier_agency.frec if use_frec else sub_tier_agency.cgac)
            obj['funding_agency_code'] = (agency_data.frec_code if use_frec else agency_data.cgac_code)
            obj['funding_agency_name'] = agency_data.agency_name
        except KeyError:
            logger.info('WARNING: MissingSubtierCGAC: The funding sub-tier cgac_code: %s does not exist in cgac table. The FPDS-provided funding sub-tier agency name (if given) for this cgac_code is %s. The award has been loaded with funding_agency_code 999.', obj['funding_sub_tier_agency_co'], obj['funding_sub_tier_agency_na'])
            obj['funding_agency_code'] = '999'
            obj['funding_agency_name'] = None
    if obj['place_of_perform_country_c']:
        calculate_ppop_fields(obj, sess, county_by_name, county_by_code, state_code_list, country_list)
    if obj['legal_entity_country_code']:
        calculate_legal_entity_fields(obj, sess, county_by_code, state_code_list, country_list)
    obj['business_categories'] = get_business_categories(row=obj, data_type='fpds')
    if (obj['awardee_or_recipient_uniqu'] and (obj['awardee_or_recipient_uniqu'] in exec_comp_dict.keys())):
        exec_comp = exec_comp_dict[obj['awardee_or_recipient_uniqu']]
        for i in range(1, 6):
            obj['high_comp_officer{}_full_na'.format(i)] = exec_comp['officer{}_name'.format(i)]
            obj['high_comp_officer{}_amount'.format(i)] = exec_comp['officer{}_amt'.format(i)]
    else:
        for i in range(1, 6):
            obj['high_comp_officer{}_full_na'.format(i)] = None
            obj['high_comp_officer{}_amount'.format(i)] = None
    if (atom_type == 'award'):
        unique_award_string_list = ['CONT_AWD']
        key_list = ['piid', 'agency_id', 'parent_award_id', 'referenced_idv_agency_iden']
    else:
        unique_award_string_list = ['CONT_IDV']
        key_list = ['piid', 'agency_id']
    for item in key_list:
        unique_award_string_list.append((obj.get(item) or '-none-'))
    obj['unique_award_key'] = '_'.join(unique_award_string_list).upper()
    key_list = ['agency_id', 'referenced_idv_agency_iden', 'piid', 'award_modification_amendme', 'parent_award_id', 'transaction_number']
    idv_list = ['agency_id', 'piid', 'award_modification_amendme']
    unique_string = ''
    for item in key_list:
        if (len(unique_string) > 0):
            unique_string += '_'
        if ((atom_type == 'award') or (item in idv_list)):
            unique_string += (obj.get(item) or '-none-')
        else:
            unique_string += '-none-'
    obj['detached_award_proc_unique'] = unique_string
    return obj
Calculate values that aren't in any feed but can be calculated.

Args:
    obj: a dictionary containing the details we need to derive from and to
    sess: the database connection
    sub_tier_list: a dictionary containing all the sub tier agency information keyed by sub tier agency code
    county_by_name: a dictionary containing all county codes, keyed by state and county name
    county_by_code: a dictionary containing all county names, keyed by state and county code
    state_code_list: a dictionary containing all state names, keyed by state code
    country_list: a dictionary containing all country names, keyed by country code
    exec_comp_dict: a dictionary containing all the data for Executive Compensation data keyed by DUNS number
    atom_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'

Returns:
    the object originally passed in with newly-calculated values added
def calculate_remaining_fields(obj, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, atom_type):
    " Calculate values that aren't in any feed but can be calculated.\n\n        Args:\n            obj: a dictionary containing the details we need to derive from and to\n            sess: the database connection\n            sub_tier_list: a dictionary containing all the sub tier agency information keyed by sub tier agency code\n            county_by_name: a dictionary containing all county codes, keyed by state and county name\n            county_by_code: a dictionary containing all county names, keyed by state and county code\n            state_code_list: a dictionary containing all state names, keyed by state code\n            country_list: a dictionary containing all country names, keyed by country code\n            exec_comp_dict: a dictionary containing all the data for Executive Compensation data keyed by DUNS number\n            atom_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'\n\n        Returns:\n            the object originally passed in with newly-calculated values added\n    "
    obj['awarding_agency_code'] = None
    obj['awarding_agency_name'] = None
    obj['funding_agency_code'] = None
    obj['funding_agency_name'] = None
    obj['place_of_perform_county_co'] = None
    obj['legal_entity_county_code'] = None
    obj['legal_entity_county_name'] = None
    obj['detached_award_proc_unique'] = None
    if obj['awarding_sub_tier_agency_c']:
        try:
            sub_tier_agency = sub_tier_list[obj['awarding_sub_tier_agency_c']]
            use_frec = sub_tier_agency.is_frec
            agency_data = (sub_tier_agency.frec if use_frec else sub_tier_agency.cgac)
            obj['awarding_agency_code'] = (agency_data.frec_code if use_frec else agency_data.cgac_code)
            obj['awarding_agency_name'] = agency_data.agency_name
        except KeyError:
            logger.info('WARNING: MissingSubtierCGAC: The awarding sub-tier cgac_code: %s does not exist in cgac table. The FPDS-provided awarding sub-tier agency name (if given) for this cgac_code is %s. The award has been loaded with awarding_agency_code 999.', obj['awarding_sub_tier_agency_c'], obj['awarding_sub_tier_agency_n'])
            obj['awarding_agency_code'] = '999'
            obj['awarding_agency_name'] = None
    if obj['funding_sub_tier_agency_co']:
        try:
            sub_tier_agency = sub_tier_list[obj['funding_sub_tier_agency_co']]
            use_frec = sub_tier_agency.is_frec
            agency_data = (sub_tier_agency.frec if use_frec else sub_tier_agency.cgac)
            obj['funding_agency_code'] = (agency_data.frec_code if use_frec else agency_data.cgac_code)
            obj['funding_agency_name'] = agency_data.agency_name
        except KeyError:
            logger.info('WARNING: MissingSubtierCGAC: The funding sub-tier cgac_code: %s does not exist in cgac table. The FPDS-provided funding sub-tier agency name (if given) for this cgac_code is %s. The award has been loaded with funding_agency_code 999.', obj['funding_sub_tier_agency_co'], obj['funding_sub_tier_agency_na'])
            obj['funding_agency_code'] = '999'
            obj['funding_agency_name'] = None
    if obj['place_of_perform_country_c']:
        calculate_ppop_fields(obj, sess, county_by_name, county_by_code, state_code_list, country_list)
    if obj['legal_entity_country_code']:
        calculate_legal_entity_fields(obj, sess, county_by_code, state_code_list, country_list)
    obj['business_categories'] = get_business_categories(row=obj, data_type='fpds')
    if (obj['awardee_or_recipient_uniqu'] and (obj['awardee_or_recipient_uniqu'] in exec_comp_dict.keys())):
        exec_comp = exec_comp_dict[obj['awardee_or_recipient_uniqu']]
        for i in range(1, 6):
            obj['high_comp_officer{}_full_na'.format(i)] = exec_comp['officer{}_name'.format(i)]
            obj['high_comp_officer{}_amount'.format(i)] = exec_comp['officer{}_amt'.format(i)]
    else:
        for i in range(1, 6):
            obj['high_comp_officer{}_full_na'.format(i)] = None
            obj['high_comp_officer{}_amount'.format(i)] = None
    if (atom_type == 'award'):
        unique_award_string_list = ['CONT_AWD']
        key_list = ['piid', 'agency_id', 'parent_award_id', 'referenced_idv_agency_iden']
    else:
        unique_award_string_list = ['CONT_IDV']
        key_list = ['piid', 'agency_id']
    for item in key_list:
        unique_award_string_list.append((obj.get(item) or '-none-'))
    obj['unique_award_key'] = '_'.join(unique_award_string_list).upper()
    key_list = ['agency_id', 'referenced_idv_agency_iden', 'piid', 'award_modification_amendme', 'parent_award_id', 'transaction_number']
    idv_list = ['agency_id', 'piid', 'award_modification_amendme']
    unique_string = 
    for item in key_list:
        if (len(unique_string) > 0):
            unique_string += '_'
        if ((atom_type == 'award') or (item in idv_list)):
            unique_string += (obj.get(item) or '-none-')
        else:
            unique_string += '-none-'
    obj['detached_award_proc_unique'] = unique_string
    return obj