import json
import re
import secrets
-import urllib2
+import urllib.request, urllib.error, urllib.parse
import random
class weather_renderer(renderer.debuggable_abstaining_renderer):
clear_count = 0
total_snow = 0
count = min(len(conditions), len(rain), len(snow))
- for x in xrange(0, count):
+ for x in range(0, count):
seen_rain = rain[x] > 0;
seen_snow = snow[x] > 0;
total_snow += snow[x]
lwind = ""
lprecip = ""
ltime = ""
- for x in xrange(0, count):
+ for x in range(0, count):
time = self.describe_time(x)
current = ""
chunks = 0
text_location = "Bellevue, WA"
param = "id=5786882"
- www = urllib2.urlopen('http://api.openweathermap.org/data/2.5/forecast?%s&APPID=%s&units=imperial' % (
+ www = urllib.request.urlopen('http://api.openweathermap.org/data/2.5/forecast?%s&APPID=%s&units=imperial' % (
param, secrets.openweather_key))
response = www.read()
www.close()
conditions = {}
rain = {}
snow = {}
- for x in xrange(0, count):
+ for x in range(0, count):
data = parsed_json['list'][x]
dt = data['dt_txt'] # 2019-10-07 18:00:00
date = dt.split(" ")[0]
snow[date] = []
ts[date] = 0
- for x in xrange(0, count):
+ for x in range(0, count):
data = parsed_json['list'][x]
dt = data['dt_txt'] # 2019-10-07 18:00:00
date = dt.split(" ")[0]
if (formatted_date in days_seen):
continue;
days_seen[formatted_date] = True
- num_days = len(days_seen.keys())
+ num_days = len(list(days_seen.keys()))
days_seen = {}
for date in sorted(highs.keys()):