Remove use of defaultdict
Remove the use of defaultdict to preserve Python 2.4 compatibility.
This commit is contained in:
parent
357649cba7
commit
b3c8a568a2
|
@ -23,7 +23,6 @@ import sys
|
||||||
import threading
|
import threading
|
||||||
from Queue import Queue
|
from Queue import Queue
|
||||||
from xml.dom import minidom as DOM
|
from xml.dom import minidom as DOM
|
||||||
from collections import defaultdict
|
|
||||||
try:
|
try:
|
||||||
from urlparse import parse_qs
|
from urlparse import parse_qs
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -204,11 +203,14 @@ def closestServers(client):
|
||||||
return None
|
return None
|
||||||
uh.close()
|
uh.close()
|
||||||
root = DOM.parseString(serversxml)
|
root = DOM.parseString(serversxml)
|
||||||
servers = defaultdict(list)
|
servers = {}
|
||||||
for server in root.getElementsByTagName('server'):
|
for server in root.getElementsByTagName('server'):
|
||||||
attrib = dict(server.attributes.items())
|
attrib = dict(server.attributes.items())
|
||||||
d = distance([float(client['lat']), float(client['lon'])],
|
d = distance([float(client['lat']), float(client['lon'])],
|
||||||
[float(attrib.get('lat')), float(attrib.get('lon'))])
|
[float(attrib.get('lat')), float(attrib.get('lon'))])
|
||||||
|
if d not in servers:
|
||||||
|
servers[d] = [attrib]
|
||||||
|
else:
|
||||||
servers[d].append(attrib)
|
servers[d].append(attrib)
|
||||||
|
|
||||||
closest = []
|
closest = []
|
||||||
|
|
Loading…
Reference in New Issue