Commit 250d3694 by David Robinson

Pep8 compliance changes

parent 2b5a26b0
...@@ -35,7 +35,8 @@ class ParseType(object): ...@@ -35,7 +35,8 @@ class ParseType(object):
@staticmethod @staticmethod
def convert(parse_data): def convert(parse_data):
is_parse_type = isinstance(parse_data, dict) and '__type' in parse_data is_parse_type = isinstance(parse_data, dict) and '__type' in parse_data
if not is_parse_type: return parse_data if not is_parse_type:
return parse_data
parse_type = parse_data['__type'] parse_type = parse_data['__type']
native = { native = {
...@@ -211,7 +212,8 @@ class ParseResource(ParseBase): ...@@ -211,7 +212,8 @@ class ParseResource(ParseBase):
return cls(**cls.GET('/' + resource_id)) return cls(**cls.GET('/' + resource_id))
def __init__(self, **kw): def __init__(self, **kw):
for key, value in kw.items(): setattr(self, key, value) for key, value in kw.items():
setattr(self, key, value)
def _to_native(self): def _to_native(self):
# serializes all attributes that need to be persisted on Parse # serializes all attributes that need to be persisted on Parse
...@@ -228,7 +230,7 @@ class ParseResource(ParseBase): ...@@ -228,7 +230,7 @@ class ParseResource(ParseBase):
def _set_object_id(self, value): def _set_object_id(self, value):
if hasattr(self, '_object_id'): if hasattr(self, '_object_id'):
raise ValueError, 'Can not re-set object id' raise ValueError('Can not re-set object id')
self._object_id = value self._object_id = value
def _get_updated_datetime(self): def _get_updated_datetime(self):
...@@ -286,7 +288,8 @@ class Object(ParseResource): ...@@ -286,7 +288,8 @@ class Object(ParseResource):
@classmethod @classmethod
def factory(cls, class_name): def factory(cls, class_name):
class DerivedClass(cls): pass class DerivedClass(cls):
pass
DerivedClass.__name__ = class_name DerivedClass.__name__ = class_name
return DerivedClass return DerivedClass
...@@ -306,7 +309,8 @@ class Object(ParseResource): ...@@ -306,7 +309,8 @@ class Object(ParseResource):
@property @property
def _absolute_url(self): def _absolute_url(self):
if not self.objectId: return None if not self.objectId:
return None
return '/'.join([self.__class__.ENDPOINT_ROOT, self.objectId]) return '/'.join([self.__class__.ENDPOINT_ROOT, self.objectId])
......
...@@ -54,7 +54,8 @@ class Queryset(object): ...@@ -54,7 +54,8 @@ class Queryset(object):
yield self._results.pop(0) yield self._results.pop(0)
def where(self, **kw): def where(self, **kw):
for key, value in kw.items(): self.eq(key, value) for key, value in kw.items():
self.eq(key, value)
return self return self
def eq(self, name, value): def eq(self, name, value):
...@@ -102,8 +103,10 @@ class Queryset(object): ...@@ -102,8 +103,10 @@ class Queryset(object):
def get(self): def get(self):
results = self._fetch() results = self._fetch()
if len(results) == 0: raise QueryResourceDoesNotExist if len(results) == 0:
if len(results) >= 2: raise QueryResourceMultipleResultsReturned raise QueryResourceDoesNotExist
if len(results) >= 2:
raise QueryResourceMultipleResultsReturned
return results[0] return results[0]
def _fetch(self): def _fetch(self):
......
...@@ -56,12 +56,14 @@ class User(ParseResource): ...@@ -56,12 +56,14 @@ class User(ParseResource):
@staticmethod @staticmethod
def signup(username, password, **kw): def signup(username, password, **kw):
return User(**User.POST('', username=username, password=password, **kw)) return User(**User.POST('', username=username, password=password,
**kw))
@staticmethod @staticmethod
def login(username, password): def login(username, password):
login_url = '/'.join([API_ROOT, 'login']) login_url = '/'.join([API_ROOT, 'login'])
return User(**User.GET(login_url, username=username, password=password)) return User(**User.GET(login_url, username=username,
password=password))
@staticmethod @staticmethod
def request_password_reset(email): def request_password_reset(email):
......
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