diff options
author | togakushi <togakushi@localhost> | 2011-11-26 00:20:11 +0900 |
---|---|---|
committer | togakushi <togakushi@localhost> | 2011-11-26 00:20:11 +0900 |
commit | d0f5de9291239ade5d1aa3d95b9be822cbec0048 (patch) | |
tree | 17309c946b851612a0ccb3cd69400bf393d9e121 /sphinx/websupport/storage/sqlalchemy_db.py | |
parent | dcd3408b8ab11d6677313748a0f95c9b02799be0 (diff) | |
download | sphinx-git-d0f5de9291239ade5d1aa3d95b9be822cbec0048.tar.gz |
Changed Conditional Expressions
Diffstat (limited to 'sphinx/websupport/storage/sqlalchemy_db.py')
-rw-r--r-- | sphinx/websupport/storage/sqlalchemy_db.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sphinx/websupport/storage/sqlalchemy_db.py b/sphinx/websupport/storage/sqlalchemy_db.py index dc2ec6a74..67136d1ae 100644 --- a/sphinx/websupport/storage/sqlalchemy_db.py +++ b/sphinx/websupport/storage/sqlalchemy_db.py @@ -77,7 +77,10 @@ class Node(Base): comments = [] list_stack = [comments] for r in results: - comment, vote = r if username else (r, 0) + if username: + comment, vote = r + else: + comment, vote = (r, 0) inheritance_chain = comment.path.split('.')[1:] @@ -176,7 +179,10 @@ class Comment(Base): path = self.path.split('.') node = path[0] - parent = path[-2] if len(path) > 2 else None + if len(path) > 2: + parent = path[-2] + else: + parent = None return {'text': self.text, 'username': self.username or 'Anonymous', @@ -201,8 +207,16 @@ class Comment(Base): minutes = seconds / 60 if days == 0: - dt = (minutes, 'minute') if hours == 0 else (hours, 'hour') + if hours == 0: + dt = (minutes, 'minute') + else: + dt = (hours, 'hour') else: dt = (days, 'day') - return '%s %s ago' % dt if dt[0] == 1 else '%s %ss ago' % dt + if dt[0] == 1: + ret = '%s %s ago' % dt + else: + ret = '%s %ss ago' % dt + + return ret |