send_the_raven.validator.Validator#
- class send_the_raven.validator.Validator[source]#
Bases:
Addresses
Class to validate addresses to USPS database.
- Parameters:
Example
>>> addresses = [ {"street": "123 Main St", "city": "Anytown", "state": "CA", "zip": "12345"}, {"street": "456 Oak Rd", "city": "Forest", "state": "VT", "zip": "67890"} ] >>> validator = Validator(addresses, usps_id="MY_ID") >>> valid_addresses = validator() >>> for addr in valid_addresses: >>> print(addr.street, addr.city, addr.state, addr.zip_code)
- __init__(addresses, usps_id, request_limit=10, field_mapping={'address_line_2': 'address_line_2', 'city': 'city', 'full_address': 'full_address', 'id': 'id', 'state': 'state', 'street': 'street', 'zip_code': 'zip_code'})[source]#
- __call__()[source]#
Start validation process. Will return after all async process are completed.
- Returns:
validated addresses.
- Return type:
Methods
__eq__
(value, /)Return self==value.
__getitem__
(index)__init__
(addresses, usps_id[, ...])__iter__
()__len__
()normalize_parallel
([number_of_proccesses])Normalize all addresses in parallel.
Initialize aiohttp TCPConnector with limit and ClientSession.
validate
(data, client)Request validation data to USPS database
- __init__(addresses, usps_id, request_limit=10, field_mapping={'address_line_2': 'address_line_2', 'city': 'city', 'full_address': 'full_address', 'id': 'id', 'state': 'state', 'street': 'street', 'zip_code': 'zip_code'})[source]#
- normalize_parallel(number_of_proccesses=None)#
Normalize all addresses in parallel. Uses
multiprocessing.Pool.map()
.- Parameters:
number_of_proccesses (int) – number of process
- async start_validation()[source]#
Initialize aiohttp TCPConnector with limit and ClientSession. Start validation in asyncio.
- async validate(data, client)[source]#
Request validation data to USPS database
- Parameters:
client (aiohttp.ClientSession) – Initialized aiohttp ClientSession