summaryrefslogtreecommitdiff
path: root/searx/engines/searchcode_code.py
diff options
context:
space:
mode:
authorCqoicebordel <Cqoicebordel@users.noreply.github.com>2014-12-29 21:31:04 +0100
committerCqoicebordel <Cqoicebordel@users.noreply.github.com>2014-12-29 21:31:04 +0100
commit5d977056f7aa216eae09a22c3baaff73546f6ff1 (patch)
treeffd08f6bc1d3268ec6ce8031cbdec7987dfd3763 /searx/engines/searchcode_code.py
parent576fdef440e835592f9f5c8dc25398e343687c7a (diff)
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...
Diffstat (limited to 'searx/engines/searchcode_code.py')
-rw-r--r--searx/engines/searchcode_code.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/searx/engines/searchcode_code.py b/searx/engines/searchcode_code.py
index 2ba0e52f1..0f98352c1 100644
--- a/searx/engines/searchcode_code.py
+++ b/searx/engines/searchcode_code.py
@@ -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(' ', '&nbsp; ').replace(' ', ' &nbsp;')
+ 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(' ', '&nbsp; ').replace(' ', ' &nbsp;')
content = content + "</td></tr>"
-
+
content = content + "</table></pre>"
-
+
# append result
results.append({'url': href,
'title': title,