Addresses
rigour.addresses
Postal/location address handling
This set of helpers is designed to help with the processing of real-world addresses, including composing an address from individual parts, and cleaning it up.
import rigour.addresses as format_one_line
address = {
"road": "Bahnhofstr.",
"house_number": "10",
"postcode": "86150",
"city": "Augsburg",
"state": "Bayern",
"country": "Germany",
}
address_text = format_one_line(address, country="DE")
clean_address(full)
format_address(address, country=None)
Format the given address part into a multi-line string that matches the conventions of the country of the given address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
Dict[str, Optional[str]]
|
The address parts to be combined. Common parts include: summary: A short description of the address. po_box: The PO box/mailbox number. street: The street or road name. house: The descriptive name of the house. house_number: The number of the house on the street. postal_code: The postal code or ZIP code. city: The city or town name. county: The county or district name. state: The state or province name. state_district: The state or province district name. state_code: The state or province code. country: The name of the country (words, not ISO code). country_code: A pre-normalized country code. |
required |
country
|
Optional[str]
|
ISO code for the country of the address. |
None
|
Returns:
Type | Description |
---|---|
str
|
A single-line string with the formatted address. |
Source code in rigour/addresses/format.py
format_address_line(address, country=None)
Format the given address part into a single-line string that matches the conventions of the country of the given address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
Dict[str, Optional[str]]
|
The address parts to be combined. Common parts include: summary: A short description of the address. po_box: The PO box/mailbox number. street: The street or road name. house: The descriptive name of the house. house_number: The number of the house on the street. postal_code: The postal code or ZIP code. city: The city or town name. county: The county or district name. state: The state or province name. state_district: The state or province district name. state_code: The state or province code. country: The name of the country (words, not ISO code). country_code: A pre-normalized country code. |
required |
country
|
Optional[str]
|
ISO code for the country of the address. |
None
|
Returns:
Type | Description |
---|---|
str
|
A single-line string with the formatted address. |