23 sys.setdefaultencoding(
'L1')
26 import xml.dom.minidom
as xdm
32 _urlopen = urllib.request.urlopen
36 _urlopen = urllib2.urlopen
39 _urlopen = urllib.urlopen
73 Cached = property(_getCached)
90 ObservationSitelist = property(_getObList)
94 ForecastSitelist = property(_getFcList)
144 url =
'/'.join([self.
_url,
154 rargs[
'key'] = self.
_key
155 params = [
'='.join([k,rargs[k]])
for k
in rargs.keys()]
156 params =
'&'.join(params)
157 url =
'?'.join([url,params])
158 source = _urlopen(url)
159 data = source.read(3000000)
174 return json.loads(d)[
'Resource'][
'TimeSteps'][
'TS']
188 return json.loads(d)[
'Resource'][
'TimeSteps'][
'TS']
202 return json.loads(d)[
'Resource'][
'TimeSteps'][
'TS']
223 sites = json.loads(d)[
'Locations'][
'Location']
225 result.append(
Site(**s))
248 sites = json.loads(d)[
'Locations'][
'Location']
250 result.append(
Site(**s))
266 doc = xdm.parseString(d)
267 sl = doc.getElementsByTagName(
'Location')
269 site =
Site(s.getAttribute(
'name'),
270 s.getAttribute(
'id'),
271 s.getAttribute(
'latitude'),
272 s.getAttribute(
'longitude'))
290 doc = xdm.parseString(d)
291 sl = doc.getElementsByTagName(
'Location')
293 site =
Site(s.getAttribute(
'name'),
294 s.getAttribute(
'id'),
295 s.getAttribute(
'latitude'),
296 s.getAttribute(
'longitude'))
314 lt1 = float(place.getLatLon()[
'lat'])
315 ln1 = float(place.getLatLon()[
'lon'])
319 lt2 = float(s.latitude)
320 ln2 = float(s.longitude)
321 d = abs(ln1-ln2) + abs(lt1-lt2)
337 object.__init__(self)
344 return self.
name < other.name