various png-related problems fixed (#311)

This commit is contained in:
Igor Chubin 2019-07-07 18:39:53 +02:00
parent 0df65139e3
commit 040b9ea7d7
3 changed files with 18 additions and 27 deletions

View file

@ -225,17 +225,10 @@ def location_processing(location, ip_addr):
query_source_location = get_location(ip_addr)
country = None
if location is None or location == 'MyLocation':
location, country = query_source_location
if not location or location == 'MyLocation':
location = ip_addr
# Let us try to use geolocation services for locations
# 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):
if is_ip(location):
location, country = get_location(location)
# here too

View file

@ -196,6 +196,7 @@ def wttr(location, request):
orig_location = location
if not png_filename:
location, override_location_name, full_address, country, query_source_location = \
location_processing(location, ip_addr)
@ -219,7 +220,7 @@ def wttr(location, request):
if png_filename:
options = {
'lang': None,
'lang': lang,
'location': location}
options.update(query)

View file

@ -288,13 +288,10 @@ def make_wttr_in_png(png_name, options=None):
"""
parsed = parse_wttrin_png_name(png_name)
print("------")
print(parsed)
print("------")
# if location is MyLocation it should be overriden
# 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']
if options is not None: