mirror of
https://github.com/searxng/searxng.git
synced 2025-07-13 08:19:17 +02:00
Flake8 and Twitter corrections
Lots of Flake8 corrections Maybe we should change the rule to allow lines of 120 chars. It seems more usable. Big twitter correction : now it outputs the words in right order...
This commit is contained in:
parent
576fdef440
commit
5d977056f7
13 changed files with 80 additions and 47 deletions
|
@ -11,7 +11,6 @@
|
|||
from urllib import urlencode
|
||||
from json import loads
|
||||
import cgi
|
||||
import re
|
||||
|
||||
# engine dependent config
|
||||
categories = ['it']
|
||||
|
@ -33,7 +32,7 @@ def request(query, params):
|
|||
# get response from search-request
|
||||
def response(resp):
|
||||
results = []
|
||||
|
||||
|
||||
search_results = loads(resp.text)
|
||||
|
||||
# parse results
|
||||
|
@ -41,21 +40,22 @@ def response(resp):
|
|||
href = result['url']
|
||||
title = "" + result['name'] + " - " + result['filename']
|
||||
content = result['repo'] + "<br />"
|
||||
|
||||
|
||||
lines = dict()
|
||||
for line, code in result['lines'].items():
|
||||
lines[int(line)] = code
|
||||
|
||||
content = content + '<pre class="code-formatter"><table class="code">'
|
||||
for line, code in sorted(lines.items()):
|
||||
content = content + '<tr><td class="line-number" style="padding-right:5px;">'
|
||||
content = content + str(line) + '</td><td class="code-snippet">'
|
||||
# Replace every two spaces with ' &nbps;' to keep formatting while allowing the browser to break the line if necessary
|
||||
content = content + cgi.escape(code).replace('\t', ' ').replace(' ', ' ').replace(' ', ' ')
|
||||
content = content + '<tr><td class="line-number" style="padding-right:5px;">'
|
||||
content = content + str(line) + '</td><td class="code-snippet">'
|
||||
# Replace every two spaces with ' &nbps;' to keep formatting
|
||||
# while allowing the browser to break the line if necessary
|
||||
content = content + cgi.escape(code).replace('\t', ' ').replace(' ', ' ').replace(' ', ' ')
|
||||
content = content + "</td></tr>"
|
||||
|
||||
|
||||
content = content + "</table></pre>"
|
||||
|
||||
|
||||
# append result
|
||||
results.append({'url': href,
|
||||
'title': title,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue