Comments, code simplification
This commit is contained in:
parent
0096adccf7
commit
6c6fb03040
11
speedtest.py
11
speedtest.py
|
|
@ -1376,28 +1376,25 @@ class Speedtest(object):
|
||||||
|
|
||||||
for attrib in attriblist:
|
for attrib in attriblist:
|
||||||
if servers and int(attrib.get('id')) not in servers:
|
if servers and int(attrib.get('id')) not in servers:
|
||||||
|
# Not one of the preselected servers
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (int(attrib.get('id')) in self.config['ignore_servers']
|
if (int(attrib.get('id')) in self.config['ignore_servers']
|
||||||
or int(attrib.get('id')) in exclude):
|
or int(attrib.get('id')) in exclude):
|
||||||
|
# One of the specifically excluded or ignored servers
|
||||||
continue
|
continue
|
||||||
|
|
||||||
host, port = attrib['host'].split(':')
|
host, port = attrib['host'].split(':')
|
||||||
attrib['host'] = (host, int(port))
|
attrib['host'] = (host, int(port))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = distance(self.lat_lon,
|
d = attrib['d'] = distance(self.lat_lon,
|
||||||
(float(attrib.get('lat')),
|
(float(attrib.get('lat')),
|
||||||
float(attrib.get('lon'))))
|
float(attrib.get('lon'))))
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
attrib['d'] = d
|
self.servers.setdefault(d, []).append(attrib)
|
||||||
|
|
||||||
try:
|
|
||||||
self.servers[d].append(attrib)
|
|
||||||
except KeyError:
|
|
||||||
self.servers[d] = [attrib]
|
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue