mirror of
https://github.com/chubin/wttr.in
synced 2025-01-26 02:34:59 +00:00
initial json support (fixes #331)
This commit is contained in:
parent
00c63a8b42
commit
c465dfe08f
1 changed files with 10 additions and 1 deletions
|
@ -212,7 +212,16 @@ def render_line(line, data, query):
|
|||
|
||||
return re.sub(r'%[^%]*[a-zA-Z]', render_symbol, line)
|
||||
|
||||
def format_weather_data(format_line, location, override_location, data, query):
|
||||
def render_json(data):
|
||||
output = json.dumps(data, indent=4, sort_keys=True)
|
||||
|
||||
output = "\n".join(
|
||||
re.sub('"[^"]*worldweatheronline[^"]*"', '""', line) if "worldweatheronline" in line else line
|
||||
for line in output.splitlines()) + "\n"
|
||||
|
||||
return output
|
||||
|
||||
def format_weather_data(format_line, location, override_location, full_address, data, query):
|
||||
"""
|
||||
Format information about current weather `data` for `location`
|
||||
with specified in `format_line` format
|
||||
|
|
Loading…
Reference in a new issue