Missed date, and use the proper icon!
This commit is contained in:
parent
455379986e
commit
cc126550f2
1 changed files with 38 additions and 18 deletions
36
bom_xml.py
36
bom_xml.py
|
@ -44,19 +44,39 @@ new = {}
|
||||||
#current = a['forecast-period'][0]
|
#current = a['forecast-period'][0]
|
||||||
weather = {}
|
weather = {}
|
||||||
|
|
||||||
# THe first forecast perios doesn't always have the temperature and other bits
|
# The first forecast period doesn't always have the temperature and other bits
|
||||||
# I chose to just switch to tomorrow
|
# I get the overnight low and forecast to substitute when this happens.
|
||||||
|
|
||||||
if (type(belco['forecast-period'][0]) == type(collections.OrderedDict())):
|
if (type(belco['forecast-period'][0]) == type(collections.OrderedDict())):
|
||||||
start = 1
|
night = 1
|
||||||
else:
|
else:
|
||||||
start = 0
|
night = 0
|
||||||
|
|
||||||
weather['today'] = belco['forecast-period'][start]
|
weather['today'] = belco['forecast-period'][0]
|
||||||
weather['tomorrow'] = belco['forecast-period'][start+1]
|
weather['tomorrow'] = belco['forecast-period'][1]
|
||||||
weather['day_after'] = belco['forecast-period'][start+2]
|
weather['day_after'] = belco['forecast-period'][2]
|
||||||
|
|
||||||
for day in weather.keys():
|
|
||||||
|
if night:
|
||||||
|
for day in weather.keys():
|
||||||
|
new[day] = {}
|
||||||
|
if (day == 'today'):
|
||||||
|
new[day]['day'] = 'Tonight'
|
||||||
|
new[day]['max'] = [a for a in weather['tomorrow']['element'] if a['@type'] == 'air_temperature_minimum'][0]['#text']
|
||||||
|
new[day]['icon'] = bom_icons[weather['today']['element']['#text']]
|
||||||
|
#bom_icons[[a for a in weather['tomorrow']['element'] if a['@type'] == 'forecast_icon_code'][0]['#text']]
|
||||||
|
else:
|
||||||
|
new[day]['day'] = datetime.datetime.strptime(weather[day]['@start-time-local'], "%Y-%m-%dT%H:%M:%S%z").strftime("%A")
|
||||||
|
for el in weather[day]['element']:
|
||||||
|
if type(el) == type(collections.OrderedDict()):
|
||||||
|
if el['@type'] == "forecast_icon_code":
|
||||||
|
new[day]['icon'] = bom_icons[el['#text']]
|
||||||
|
elif el['@type'] == 'air_temperature_maximum':
|
||||||
|
new[day]['max'] = el['#text']
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
for day in weather.keys():
|
||||||
new[day] = {}
|
new[day] = {}
|
||||||
new[day]['day'] = datetime.datetime.strptime(weather[day]['@start-time-local'], "%Y-%m-%dT%H:%M:%S%z").strftime("%A")
|
new[day]['day'] = datetime.datetime.strptime(weather[day]['@start-time-local'], "%Y-%m-%dT%H:%M:%S%z").strftime("%A")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue