How to use the zipcodes.is_valid function in zipcodes

To help you get started, we’ve selected a few zipcodes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OperationCode / operationcode_pyback / ocbot / pipeline / slash_command_handlers / lunch_handler.py View on Github external
def split_params(param_text):
    if not param_text:  # no params, default random zip code, 20 miles
        return {'location': random_zip(), 'range': '20'}

    params = param_text.split()

    if len(params) == 2:  # two values
        return two_params(params[0], params[1])

    if len(params) == 1 and is_valid(params[0]):  # one value
        return {'location': params[0], 'range': '20'}

    else:
        return {'location': random_zip(), 'range': '20'}
github OperationCode / operationcode_pyback / ocbot / pipeline / slash_command_handlers / lunch_handler.py View on Github external
def random_zip():
    random_zip = 0
    while not is_valid(str(random_zip)):
        range_start = 10 ** (4)
        range_end = (10 ** 5) - 1
        random_zip = randint(range_start, range_end)

    return str(random_zip)
github OperationCode / operationcode_pyback / ocbot / pipeline / slash_command_handlers / lunch_handler.py View on Github external
def two_params(first_param, second_param):
    if is_valid(first_param) and within_lunch_range(second_param):
        return {'location': first_param, 'range': second_param}
    else:
        return {'location': random_zip(), 'range': '20'}

zipcodes

Query U.S. state zipcodes without SQLite.

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages