Commit 99fb1d27 by David Robinson

Changes for pep8 compliance

parent 10e3bb94
......@@ -118,9 +118,10 @@ class ParseObject(ParseBase):
response_dict = self._executeCall(uri, 'GET')
self._populateFromDict(response_dict)
def _isGeoPoint(self,value):
def _isGeoPoint(self, value):
if isinstance(value, str):
return re.search("\\bPOINT\\(\\b([-+]?\\d*\\.\\d+|\\d+) ([-+]?\\d*\\.\\d+|\\d+)\\)", value, re.I)
return re.search("\\bPOINT\\(\\b([-+]?\\d*\\.\\d+|\\d+) " +
"([-+]?\\d*\\.\\d+|\\d+)\\)", value, re.I)
def _populateFromDict(self, attrs_dict):
if 'objectId' in attrs_dict:
......@@ -151,10 +152,10 @@ class ParseObject(ParseBase):
value = {'__type': 'Bytes',
'base64': base64.b64encode(value)}
elif self._isGeoPoint(value):
coordinates=re.findall(r'[-+]?\d*\.\d+|\d+',value)
value= {'__type':'GeoPoint',
'latitude':float(coordinates[0]),
'longitude':float(coordinates[1])}
coordinates = re.findall(r'[-+]?\d*\.\d+|\d+', value)
value = {'__type': 'GeoPoint',
'latitude': float(coordinates[0]),
'longitude': float(coordinates[1])}
return (key, value)
......@@ -170,7 +171,8 @@ class ParseObject(ParseBase):
value = ParseBinaryDataWrapper(base64.b64decode(
value['base64']))
elif value['__type'] == 'GeoPoint':
value = 'POINT(%s %s)'%(value['latitude'],value['longitude'])
value = 'POINT(%s %s)' % (value['latitude'],
value['longitude'])
else:
raise Exception('Invalid __type.')
......
......@@ -26,7 +26,7 @@ def test_obj(saved=False):
ret.score = 1337
ret.playerName = "Sean Plott"
ret.cheatMode = False
ret.location = "POINT(30.0 -43.21)" #"POINT(30 -43.21)"
ret.location = "POINT(30.0 -43.21)" # "POINT(30 -43.21)"
if saved:
ret.save()
return ret
......@@ -49,7 +49,7 @@ class TestParseObjectAndQuery(unittest.TestCase):
# TODO: str vs unicode
#self.assertEqual(o.playerName.__class__, unicode)
self.assertEqual(o.cheatMode.__class__, bool)
self.assertEqual(o.location,"POINT(30.0 -43.21)")
self.assertEqual(o.location, "POINT(30.0 -43.21)")
def test_object(self):
"""Test the creation, retrieval and updating of a ParseObject"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment