[python] Adding address parser Python API

This commit is contained in:
Al
2015-12-15 00:55:41 -05:00
parent b9bf5c629e
commit 842ef4526b
2 changed files with 313 additions and 0 deletions

14
python/postal/parser.py Normal file
View File

@@ -0,0 +1,14 @@
import _parser
from postal.text.encoding import safe_decode
DEFAULT_LANGUAGES = ('en',)
def parse_address(address, language=None, country=None):
'''
@param address: the address as either Unicode or a UTF-8 encoded string
@param language (optional): language code
@param country (optional): country code
'''
address = safe_decode(address, 'utf-8')
return _parser.parse_address(address, language=language, country=country)