Skip to content

Commit

Permalink
PEP 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtgay committed Jul 14, 2013
1 parent e07af01 commit 88f89f8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tahrir_api/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def badge_exists(self, badge_id):
:param badge_id: The ID of a Badge
"""

return self.session.query(Badge).filter(func.lower(Badge.id) == func.lower(badge_id)).count() != 0
return self.session.query(Badge).filter(
func.lower(Badge.id) == func.lower(badge_id)).count() != 0

def get_badge(self, badge_id):
"""
Expand All @@ -62,7 +63,8 @@ def get_badge(self, badge_id):
"""

if self.badge_exists(badge_id):
return self.session.query(Badge).filter(func.lower(Badge.id) == func.lower(badge_id)).one()
return self.session.query(Badge).filter(
func.lower(Badge.id) == func.lower(badge_id)).one()
return None

def get_all_badges(self):
Expand Down Expand Up @@ -140,11 +142,14 @@ def person_exists(self, email=None, id=None, nickname=None):

query = self.session.query(Person)
if email:
return query.filter(func.lower(Person.email) == func.lower(email)).count() != 0
return query.filter(
func.lower(Person.email) == func.lower(email)).count() != 0
elif id:
return query.filter_by(id=id).count() != 0
elif nickname:
return query.filter(func.lower(Person.nickname) == func.lower(nickname)).count() != 0
return query.filter(
func.lower(Person.nickname) == func.lower(
nickname)).count() != 0
else:
return False

Expand Down Expand Up @@ -196,11 +201,15 @@ def get_person(self, person_email=None, id=None, nickname=None):
query = self.session.query(Person)

if person_email and self.person_exists(email=person_email):
return query.filter(func.lower(Person.email) == func.lower(person_email)).one()
return query.filter(
func.lower(Person.email) == \
func.lower(person_email)).one()
elif id and self.person_exists(id=id):
return query.filter_by(id=id).one()
elif nickname and self.person_exists(nickname=nickname):
return query.filter(func.lower(Person.nickname) == func.lower(nickname)).one()
return query.filter(
func.lower(Person.nickname) == \
func.lower(nickname)).one()
else:
return None

Expand Down

0 comments on commit 88f89f8

Please sign in to comment.