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)
    def _get_zipcode(cls, zipcode: str) -> int:
        try:

            if is_valid(zipcode):
                return int(zipcode)
        except TypeError:
            pass

        return cls._random_zip()
def random_zip():
    # because what matters is good food, not close food.
    random_zip = 0
    # because strings are required for this module
    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)
    def _get_zipcode(self, zipcode_val: str) -> int:
        try:

            if is_valid(zipcode_val):
                return int(zipcode_val)
        except TypeError:
            pass

        finally:

            return LunchCommand._random_zip()
    def _random_zip() -> int:
        """
        Because what doesn't matter is close food but good food
        :return: zip_code
        :rtype: str
        """
        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 random_zip
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'}
def split_params(param_text):
    if not param_text:  # no params, default random zip code, 20 miles
        return set_values_with_default()

    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 set_values_with_default(loc=params[0])

    else:
        return set_values_with_default()
Beispiel #8
0
 def verfiy(self, body):
     input_Data = body.decode("utf-8").split('&')
     postcode = ((input_Data[0]).split('=')[1])
     city = ((input_Data[1]).split('=')[1])
     num = ((input_Data[2]).split('=')[1])
     name = ((input_Data[3]).split('=')[1])
     if (zipcodes.is_valid(postcode)):
         if (((zipcodes.matching(postcode))[0].get('city')) == city):
             numV = self.tnumVerify(num)
             if numV:
                 self.insertIntoOdoo(city, postcode, num, name)
                 return "1"  # Zip code and city exactly match and phone number is fine
             else:
                 return "2"  # Zip code and city exactly match, but phone number is not fine
         else:
             return "3"  # Zip Code and City are not matching
     else:
         return "4"  # Zip code is not found
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'}
def two_params(first_param, second_param):
    if is_valid(first_param) and within_lunch_range(second_param):
        return set_values_with_default(first_param, second_param)
    else:
        return set_values_with_default()