Commits

Anonymous committed 0b2d340

Replace ternary statements with condition and 'then' or 'else'

  • Participants
  • Parent commits 3a275f5

Comments (0)

Files changed (3)

sphinx/websupport/search/__init__.py

             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')

sphinx/websupport/storage/differ.py

             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())
 

sphinx/websupport/storage/sqlalchemystorage.py

         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)