mirror of
https://github.com/chubin/wttr.in.git
synced 2025-08-15 16:22:51 +02:00
location.py refactoring
This commit is contained in:
@ -163,10 +163,16 @@ LOCATION_BLACK_LIST = [x.strip() for x in open(BLACKLIST, 'r').readlines()]
|
|||||||
IATA_CODES = load_iata_codes(IATA_CODES_FILE)
|
IATA_CODES = load_iata_codes(IATA_CODES_FILE)
|
||||||
|
|
||||||
def is_location_blocked(location):
|
def is_location_blocked(location):
|
||||||
|
"""
|
||||||
|
Return True if this location is blocked
|
||||||
|
or False if it is allowed
|
||||||
|
"""
|
||||||
return location is not None and location.lower() in LOCATION_BLACK_LIST
|
return location is not None and location.lower() in LOCATION_BLACK_LIST
|
||||||
|
|
||||||
|
|
||||||
def location_processing():
|
def location_processing(location, ip_addr):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
|
||||||
# if location is starting with ~
|
# if location is starting with ~
|
||||||
# or has non ascii symbols
|
# or has non ascii symbols
|
||||||
@ -198,8 +204,6 @@ def location_processing():
|
|||||||
if location is None or location == 'MyLocation':
|
if location is None or location == 'MyLocation':
|
||||||
location, country = query_source_location
|
location, country = query_source_location
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if is_ip(location):
|
if is_ip(location):
|
||||||
location, country = get_location(location)
|
location, country = get_location(location)
|
||||||
if location.startswith('@'):
|
if location.startswith('@'):
|
||||||
@ -210,3 +214,8 @@ def location_processing():
|
|||||||
|
|
||||||
location = location_canonical_name(location)
|
location = location_canonical_name(location)
|
||||||
|
|
||||||
|
return location, \
|
||||||
|
override_location_name, \
|
||||||
|
full_address, \
|
||||||
|
country, \
|
||||||
|
query_source_location
|
||||||
|
Reference in New Issue
Block a user