Skip to main content

Formatting utility for international postal addresses

Project description

International Address formatter

This is a address formatter that can format addresses in multiple formats that are common in different countries.

For formatting the addresses the worldwide.yml from OpenCageData address-formatting repository is used to format the address according to customs in the country that is been encoded.

API documentation

The complete project contains actually only one class:

AddressFormatter

Publicly accessible method prototypes are:

def __init__(self, config=None):
    pass

def format(self, address, country=None):
    pass

def one_line(self, address, country=None):
    pass

__init__

Initialize the address formatter

  • config: (optional) override default config file to use for the address formatter, defaults to config file included in this package

format

Format an address in the default layout used in the specified country. Return value may contain line breaks.

  • address: Dictionary that contains the address parts, see below for recognized keys
  • country: Country code of the formatting template to use

Recognized keys in address:

  • attention
  • house
  • road
  • house_number
  • postcode
  • city
  • town
  • village
  • county
  • state
  • country
  • suburb
  • city_district
  • state_district
  • state_code
  • neighbourhood

one_line

Works the same as format but returns a single line of text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

addressformatting-1.3.2.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

addressformatting-1.3.2-py2.py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page