summaryrefslogtreecommitdiff
path: root/gps/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'gps/client.py')
-rw-r--r--gps/client.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/gps/client.py b/gps/client.py
index 22503b13..ef7a0b69 100644
--- a/gps/client.py
+++ b/gps/client.py
@@ -132,21 +132,21 @@ class gpsjson(gpscommon):
return self
def json_unpack(self, buf):
- def asciify(d):
+ def asciify(v):
"De-Unicodify everything so we can copy dicts into Python objects."
- t = {}
- for (k, v) in d.items():
- ka = k.encode("ascii")
- if type(v) == type(u"x"):
- va = v.encode("ascii")
- elif type(v) == type({}):
- va = asciify(v)
- elif type(v) == type([]):
- va = map(asciify, v)
- else:
- va = v
- t[ka] = va
- return t
+ if type(v) == type(u"x"):
+ return v.encode("ascii")
+ elif type(v) == type({}):
+ va = {}
+ for (k, v) in v.items():
+ ka = k.encode("ascii")
+ kv = asciify(v)
+ va[ka] = kv
+ return va
+ elif type(v) == type([]):
+ return map(asciify, v)
+ else:
+ return v
try:
self.data = dictwrapper(**asciify(json.loads(buf.strip(), encoding="ascii")))
except ValueError, e: