various png-related problems fixed (#311)
This commit is contained in:
parent
0df65139e3
commit
040b9ea7d7
3 changed files with 18 additions and 27 deletions
|
|
@ -225,17 +225,10 @@ def location_processing(location, ip_addr):
|
||||||
query_source_location = get_location(ip_addr)
|
query_source_location = get_location(ip_addr)
|
||||||
|
|
||||||
country = None
|
country = None
|
||||||
if location is None or location == 'MyLocation':
|
if not location or location == 'MyLocation':
|
||||||
location, country = query_source_location
|
location = ip_addr
|
||||||
|
|
||||||
# Let us try to use geolocation services for locations
|
if is_ip(location):
|
||||||
# that were derived from IPs.
|
|
||||||
if location:
|
|
||||||
location = '~' + location
|
|
||||||
if country:
|
|
||||||
location += ", %s" % country
|
|
||||||
hide_full_address = not force_show_full_address
|
|
||||||
elif is_ip(location):
|
|
||||||
location, country = get_location(location)
|
location, country = get_location(location)
|
||||||
|
|
||||||
# here too
|
# here too
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ def wttr(location, request):
|
||||||
|
|
||||||
orig_location = location
|
orig_location = location
|
||||||
|
|
||||||
|
if not png_filename:
|
||||||
location, override_location_name, full_address, country, query_source_location = \
|
location, override_location_name, full_address, country, query_source_location = \
|
||||||
location_processing(location, ip_addr)
|
location_processing(location, ip_addr)
|
||||||
|
|
||||||
|
|
@ -219,7 +220,7 @@ def wttr(location, request):
|
||||||
|
|
||||||
if png_filename:
|
if png_filename:
|
||||||
options = {
|
options = {
|
||||||
'lang': None,
|
'lang': lang,
|
||||||
'location': location}
|
'location': location}
|
||||||
options.update(query)
|
options.update(query)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -288,13 +288,10 @@ def make_wttr_in_png(png_name, options=None):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parsed = parse_wttrin_png_name(png_name)
|
parsed = parse_wttrin_png_name(png_name)
|
||||||
print("------")
|
|
||||||
print(parsed)
|
|
||||||
print("------")
|
|
||||||
|
|
||||||
# if location is MyLocation it should be overriden
|
# if location is MyLocation it should be overriden
|
||||||
# with autodetected location (from options)
|
# with autodetected location (from options)
|
||||||
if parsed.get('location', 'MyLocation') == 'MyLocation':
|
if parsed.get('location', 'MyLocation') == 'MyLocation' or not parsed.get('location', ''):
|
||||||
del parsed['location']
|
del parsed['location']
|
||||||
|
|
||||||
if options is not None:
|
if options is not None:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue