use (query, parsed_query) args for views
This commit is contained in:
parent
8855e494cd
commit
7565baaa85
4 changed files with 26 additions and 28 deletions
|
|
@ -260,11 +260,16 @@ def format_weather_data(format_line, location, override_location, full_address,
|
||||||
output = render_line(format_line, current_condition, query)
|
output = render_line(format_line, current_condition, query)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def wttr_line(location, override_location_name, full_address, query, lang, fmt):
|
def wttr_line(query, parsed_query):
|
||||||
"""
|
"""
|
||||||
Return 1line weather information for `location`
|
Return 1line weather information for `location`
|
||||||
in format `line_format`
|
in format `line_format`
|
||||||
"""
|
"""
|
||||||
|
location = parsed_query['location']
|
||||||
|
override_location_name = parsed_query['override_location_name']
|
||||||
|
full_address = parsed_query['full_address']
|
||||||
|
lang = parsed_query['lang']
|
||||||
|
fmt = parsed_query['view']
|
||||||
|
|
||||||
format_line = query.get('format', fmt or '')
|
format_line = query.get('format', fmt or '')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,12 @@ import constants
|
||||||
import parse_query
|
import parse_query
|
||||||
import globals
|
import globals
|
||||||
|
|
||||||
def get_moon(location, html=False, lang=None, query=None):
|
def get_moon(query, parsed_query):
|
||||||
|
|
||||||
|
location = parsed_query['orig_location']
|
||||||
|
html = parsed_query['html_output']
|
||||||
|
lang = parsed_query['lang']
|
||||||
|
|
||||||
if query is None:
|
if query is None:
|
||||||
query = {}
|
query = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,15 @@ def _is_invalid_location(location):
|
||||||
if '.png' in location:
|
if '.png' in location:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_wetter(location, ip, html=False, lang=None, query=None, location_name=None, full_address=None, url=None):
|
def get_wetter(query, parsed_query):
|
||||||
|
|
||||||
|
location = parsed_query['location']
|
||||||
|
ip = parsed_query['ip_addr']
|
||||||
|
html = parsed_query['html_output']
|
||||||
|
lang = parsed_query['lang']
|
||||||
|
location_name = parsed_query['override_location_name']
|
||||||
|
full_address = parsed_query['full_address']
|
||||||
|
url = parsed_query['request_url']
|
||||||
|
|
||||||
local_url = url
|
local_url = url
|
||||||
local_location = location
|
local_location = location
|
||||||
|
|
|
||||||
|
|
@ -200,13 +200,7 @@ def _response(parsed_query, query, fast_mode=False):
|
||||||
# so we handle it with all available logic
|
# so we handle it with all available logic
|
||||||
|
|
||||||
if parsed_query["view"] or 'format' in query:
|
if parsed_query["view"] or 'format' in query:
|
||||||
response_text = wttr_line(
|
response_text = wttr_line(query, parsed_query)
|
||||||
parsed_query['location'],
|
|
||||||
parsed_query['override_location_name'],
|
|
||||||
parsed_query['full_address'],
|
|
||||||
query,
|
|
||||||
parsed_query['lang'],
|
|
||||||
parsed_query['view'])
|
|
||||||
return cache.store(cache_signature, response_text)
|
return cache.store(cache_signature, response_text)
|
||||||
|
|
||||||
if parsed_query.get('png_filename'):
|
if parsed_query.get('png_filename'):
|
||||||
|
|
@ -219,25 +213,11 @@ def _response(parsed_query, query, fast_mode=False):
|
||||||
output = fmt.png.make_wttr_in_png(
|
output = fmt.png.make_wttr_in_png(
|
||||||
parsed_query['png_filename'], options=options)
|
parsed_query['png_filename'], options=options)
|
||||||
else:
|
else:
|
||||||
orig_location = parsed_query['orig_location']
|
loc = (parsed_query['orig_location'] or "").lower()
|
||||||
if orig_location and \
|
if loc == 'moon' or loc.startswith('moon@'):
|
||||||
(orig_location.lower() == 'moon' or \
|
output = get_moon(query, parsed_query)
|
||||||
orig_location.lower().startswith('moon@')):
|
|
||||||
output = get_moon(
|
|
||||||
parsed_query['orig_location'],
|
|
||||||
html=parsed_query['html_output'],
|
|
||||||
lang=parsed_query['lang'],
|
|
||||||
query=query)
|
|
||||||
else:
|
else:
|
||||||
output = get_wetter(
|
output = get_wetter(query, parsed_query)
|
||||||
parsed_query['location'],
|
|
||||||
parsed_query['ip_addr'],
|
|
||||||
html=parsed_query['html_output'],
|
|
||||||
lang=parsed_query['lang'],
|
|
||||||
query=query,
|
|
||||||
location_name=parsed_query['override_location_name'],
|
|
||||||
full_address=parsed_query['full_address'],
|
|
||||||
url=parsed_query['request_url'],)
|
|
||||||
|
|
||||||
if query.get('days', '3') != '0' and not query.get('no-follow-line'):
|
if query.get('days', '3') != '0' and not query.get('no-follow-line'):
|
||||||
if parsed_query['html_output']:
|
if parsed_query['html_output']:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue