mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Replace ternary statements with condition and 'then' or 'else'
This commit is contained in:
parent
a2919aab47
commit
87ceced3b6
@ -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')
|
||||
|
@ -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 '<span class="%s">%s</span>\n' % (css_class, text.rstrip())
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user