location.py refactoring
This commit is contained in:
parent
af621947d9
commit
218acd8b9d
1 changed files with 44 additions and 35 deletions
|
|
@ -163,10 +163,16 @@ LOCATION_BLACK_LIST = [x.strip() for x in open(BLACKLIST, 'r').readlines()]
|
|||
IATA_CODES = load_iata_codes(IATA_CODES_FILE)
|
||||
|
||||
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
|
||||
|
||||
|
||||
def location_processing():
|
||||
def location_processing(location, ip_addr):
|
||||
"""
|
||||
"""
|
||||
|
||||
# if location is starting with ~
|
||||
# or has non ascii symbols
|
||||
|
|
@ -198,8 +204,6 @@ def location_processing():
|
|||
if location is None or location == 'MyLocation':
|
||||
location, country = query_source_location
|
||||
|
||||
|
||||
|
||||
if is_ip(location):
|
||||
location, country = get_location(location)
|
||||
if location.startswith('@'):
|
||||
|
|
@ -210,3 +214,8 @@ def location_processing():
|
|||
|
||||
location = location_canonical_name(location)
|
||||
|
||||
return location, \
|
||||
override_location_name, \
|
||||
full_address, \
|
||||
country, \
|
||||
query_source_location
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue