Sfoglia il codice sorgente

[enh] use format to concatenate strings

jibe-b 7 anni fa
parent
commit
5278fa666c
1 ha cambiato i file con 6 aggiunte e 4 eliminazioni
  1. 6
    4
      searx/engines/arxiv.py

+ 6
- 4
searx/engines/arxiv.py Vedi File

@@ -48,14 +48,16 @@ def response(resp):
48 48
 
49 49
         url = entry.xpath('.//id')[0].text
50 50
 
51
-        content = entry.xpath('.//summary')[0].text
51
+        content_string = '{doi_content}{abstract_content}'
52
+       
53
+        abstract = entry.xpath('.//summary')[0].text
52 54
 
53 55
         #  If a doi is available, add it to the snipppet
54 56
         try:
55
-            doi = entry.xpath('.//link[@title="doi"]')[0].text
56
-            content = 'DOI: ' + doi + ' Abstract: ' + content
57
+            doi_content = entry.xpath('.//link[@title="doi"]')[0].text
58
+            content = content_string.format(doi_content=doi_content, abstract_content=abstract_content)
57 59
         except:
58
-            pass
60
+            content = content_string.format(abstract_content=abstract_content)
59 61
 
60 62
         if len(content) > 300:
61 63
                     content = content[0:300] + "..."