From 87ceced3b613f9436b8c411760239176550ae341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Sat, 8 Jan 2011 19:55:47 +0100 Subject: [PATCH] Replace ternary statements with condition and 'then' or 'else' --- sphinx/websupport/search/__init__.py | 4 ++-- sphinx/websupport/storage/differ.py | 4 ++-- sphinx/websupport/storage/sqlalchemystorage.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sphinx/websupport/search/__init__.py b/sphinx/websupport/search/__init__.py index 9410973ca..385c3fa97 100644 --- a/sphinx/websupport/search/__init__.py +++ b/sphinx/websupport/search/__init__.py @@ -104,9 +104,9 @@ class BaseSearch(object): return '' context_start = max(res.start() - length/2, 0) context_end = context_start + length - context = ''.join(['...' if context_start > 0 else '', + context = ''.join([context_start > 0 and '...' or '', text[context_start:context_end], - '...' if context_end < len(text) else '']) + context_end < len(text) and '...' or '']) try: return unicode(context, errors='ignore') diff --git a/sphinx/websupport/storage/differ.py b/sphinx/websupport/storage/differ.py index cd57bae81..33fe54f34 100644 --- a/sphinx/websupport/storage/differ.py +++ b/sphinx/websupport/storage/differ.py @@ -62,9 +62,9 @@ class CombinedHtmlDiff(object): return '' if next is not None and next[0] == '?': - tag = 'ins' if prefix == '+' else 'del' + tag = prefix == '+' and 'ins' or 'del' text = self._highlight_text(text, next, tag) - css_class = 'prop-added' if prefix == '+' else 'prop-removed' + css_class = prefix == '+' and 'prop-added' or 'prop-removed' return '%s\n' % (css_class, text.rstrip()) diff --git a/sphinx/websupport/storage/sqlalchemystorage.py b/sphinx/websupport/storage/sqlalchemystorage.py index b2efe82b6..e6eccfe97 100644 --- a/sphinx/websupport/storage/sqlalchemystorage.py +++ b/sphinx/websupport/storage/sqlalchemystorage.py @@ -45,7 +45,7 @@ class SQLAlchemyStorage(StorageBackend): session = Session() node = session.query(Node).filter(Node.id == id).first() session.close() - return True if node else False + return bool(node) def add_node(self, id, document, source): node = Node(id, document, source)