def parse_institution_address(address, city, state_province,
                              country, postal_code, country_code):
    """Parse an institution address."""
    address_list = force_list(address)
    state_province = match_us_state(state_province) or state_province

    postal_code = force_list(postal_code)
    country = force_list(country)
    country_code = match_country_code(country_code)

    if isinstance(postal_code, (tuple, list)):
        postal_code = ', '.join(postal_code)

    if isinstance(country, (tuple, list)):
        country = ', '.join(set(country))

    if not country_code and country:
        country_code = match_country_name_to_its_code(country)

    if not country_code and state_province and state_province in us_state_to_iso_code.values():
        country_code = 'US'

    return {
        'cities': force_list(city),
        'country_code': country_code,
        'postal_address': address_list,
        'postal_code': postal_code,
        'state': state_province,
    }
def parse_institution_address ( address , city , state_province , country , postal_code , country_code ) : address_list = force_list ( address ) state_province = match_us_state ( state_province ) or state_province postal_code = force_list ( postal_code ) country = force_list ( country ) country_code = match_country_code ( country_code ) if isinstance ( postal_code , ( tuple , list ) ) : postal_code = ', ' . join ( postal_code ) if isinstance ( country , ( tuple , list ) ) : country = ', ' . join ( set ( country ) ) if not country_code and country : country_code = match_country_name_to_its_code ( country ) if not country_code and state_province and state_province in us_state_to_iso_code . values ( ) : country_code = 'US' return { 'cities' : force_list ( city ) , 'country_code' : country_code , 'postal_address' : address_list , 'postal_code' : postal_code , 'state' : state_province , }
Parse an institution address.