Skip to content

Commit 0124f7c

Browse files
committed
Add flake8 and fix whitespace problems
1 parent 3ea6f05 commit 0124f7c

6 files changed

+70
-38
lines changed

.flake8

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[flake8]
2+
ignore =
3+
# Module imported but unused
4+
F401,
5+
# Line too long
6+
E501,
7+
# Indentation contains tabs
8+
W191,
9+
ZZZZ # allow comma on last entry
10+
select =
11+
# Missing whitespace around modulo
12+
E228,
13+
# Blank line at end of file
14+
W391,
15+
# Block comment should start with '# '
16+
E265,
17+
# Whitespace before '('
18+
E211,
19+
# Trailing whitespace
20+
W291,
21+
# Multiple spaces after operator
22+
E222,
23+
# Multiple imports on one line
24+
E401,
25+
# Indentation contains mixed spaces and tabs
26+
E101,
27+
ZZZZ # allow comma on last entry
28+
filename = *.py

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ jdk:
44
env:
55
global:
66
- secure: DbveaxDMtEP+/Er6ktKCP+P42uDU8xXWRBlVGaqVNU3muaRmmZtj8ngAARxfzY0f9amlJlCavqkEIAumQl9BYKPWIra28ylsLNbzAoCIi8alf9WLgddKwVWsTcZo9+UYocuY6UivJVkofycfFJ1blw/83dWMG0/TiW6s/SrwoDw=
7+
install:
8+
- pip install --user flake8
79
script:
810
- "./gradle_init.sh"
911
- gradle assemble
1012
- "./gradle_clean.sh"
1113
- ant
1214
- bin/start.sh
15+
# Run flake8
16+
- flake8 bin
1317
before_script:
1418
- pip install --user codecov
15-
install: true
1619
after_success:
1720
- sh .utility/push-javadoc-to-gh-pages.sh
1821
- bash <(curl -s https://codecov.io/bash)

bin/search.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
query = "http://127.0.0.1:9000/api/search.json?q={}".format(searchTerm)
99

1010
try:
11-
fetchData = urllib.urlopen(query).read()
11+
fetchData = urllib.urlopen(query).read()
1212
except Exception, e:
13-
print "! Sorry, something went wrong:"
14-
print "! Error: %s"%e
15-
sys.exit(1)
13+
print "! Sorry, something went wrong:"
14+
print "! Error: %s" % e
15+
sys.exit(1)
1616

1717
statuses = json.loads(fetchData).get("statuses")
1818
texts = [tweet.get("text") for tweet in statuses]
1919

2020
for text in texts:
21-
print text
22-
21+
print text

bin/search_fossasia.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Returns all tweet text lines related to fossasia
1+
# Returns all tweet text lines related to fossasia
22
import urllib
33
from urllib import request
44
import html
@@ -9,21 +9,21 @@
99
search_term = sys.argv[1]
1010
query = "http://loklak.org/api/search.json?q={}".format(search_term)
1111

12-
#get file and decode
12+
# Get file and decode
1313
try:
1414
json_data = urllib.request.Request(query)
1515
with urllib.request.urlopen(json_data) as data:
1616
data1 = str(data.read().decode('utf-8'))
1717
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
1818
data1 = data1.translate(non_bmp_map)
1919
except Exception as e:
20-
print ("! Sorry, something went wrong:")
21-
print ("! Error: %s"%e)
22-
sys.exit(1)
20+
print("! Sorry, something went wrong:")
21+
print("! Error: %s" % e)
22+
sys.exit(1)
2323

24-
#output tweets
24+
# Output tweets
2525
statuses = json.loads(data1).get("statuses")
2626
texts = [tweet.get("text") for tweet in statuses]
2727

2828
for text in texts:
29-
print (text)
29+
print(text)

bin/search_nerdwithak.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
#Uses Python3
2-
import urllib.request, json, sys
1+
# Uses Python3
2+
import urllib.request
3+
import json
4+
import sys
35

4-
#Get JSON file
6+
# Get JSON file
57
data = urllib.request.urlopen("127.0.0.1:9000/api/search.json?q=%s" % (sys.argv[1]))
68

7-
#Read and parse JSON
9+
# Read and parse JSON
810
data = data.read().decode('utf-8')
911
data = json.loads(data)
1012

11-
#Print out tweets
12-
for tweet in data["statuses"]:
13-
print(tweet["text"])
13+
# Print out tweets
14+
for tweet in data["statuses"]:
15+
print(tweet["text"])

bin/test_piotr.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python
22
import os
33
import requests
44

55

66
def print_response_from_file(file_name, path):
7-
current_file = open(path + file_name, 'r', encoding="utf8")
8-
for line in current_file:
9-
response = requests.get("http://127.0.0.1:9000/api/search.json?q=" + line)
10-
x = response.json()
11-
try:
12-
print(x['statuses'])
13-
except Exception as e:
14-
print(e)
7+
current_file = open(path + file_name, 'r', encoding="utf8")
8+
for line in current_file:
9+
response = requests.get("http://127.0.0.1:9000/api/search.json?q=" + line)
10+
x = response.json()
11+
try:
12+
print(x['statuses'])
13+
except Exception as e:
14+
print(e)
1515

1616

1717
def print_all_files_lines_in_defined_directory(path):
18-
for fn in os.listdir(path):
19-
if fn == 'README.txt':
20-
pass
21-
elif fn.endswith(".txt"):
22-
print_response_from_file(fn, path)
23-
else:
24-
pass
18+
for fn in os.listdir(path):
19+
if fn == 'README.txt':
20+
pass
21+
elif fn.endswith(".txt"):
22+
print_response_from_file(fn, path)
23+
else:
24+
pass
2525

2626

2727
if __name__ == "__main__":
28-
print_all_files_lines_in_defined_directory('../test/queries/')
28+
print_all_files_lines_in_defined_directory('../test/queries/')

0 commit comments

Comments
 (0)