From b3c8a568a288f6b049cd0e66263d4ed72e16f09f Mon Sep 17 00:00:00 2001 From: Andrew Parker Date: Wed, 23 Jan 2013 12:24:02 -0700 Subject: [PATCH] Remove use of defaultdict Remove the use of defaultdict to preserve Python 2.4 compatibility. --- speedtest-cli | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/speedtest-cli b/speedtest-cli index 3b63cb2..7fd7582 100755 --- a/speedtest-cli +++ b/speedtest-cli @@ -23,7 +23,6 @@ import sys import threading from Queue import Queue from xml.dom import minidom as DOM -from collections import defaultdict try: from urlparse import parse_qs except ImportError: @@ -204,12 +203,15 @@ def closestServers(client): return None uh.close() root = DOM.parseString(serversxml) - servers = defaultdict(list) + servers = {} for server in root.getElementsByTagName('server'): attrib = dict(server.attributes.items()) d = distance([float(client['lat']), float(client['lon'])], [float(attrib.get('lat')), float(attrib.get('lon'))]) - servers[d].append(attrib) + if d not in servers: + servers[d] = [attrib] + else: + servers[d].append(attrib) closest = [] for d in sorted(servers.keys()):