Fix flake8 errors.
This commit is contained in:
parent
e08c378900
commit
f51d9cc4f5
@ -13,12 +13,14 @@ if not PY2K:
|
|||||||
buffer = memoryview
|
buffer = memoryview
|
||||||
filter, map, zip = filter, map, zip
|
filter, map, zip = filter, map, zip
|
||||||
|
|
||||||
def iteritems(dikt): return iter(dikt.items()) # noqa: E731
|
def iteritems(dikt):
|
||||||
|
return iter(dikt.items()) # noqa: E731
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
else:
|
else:
|
||||||
buffer = buffer
|
buffer = buffer
|
||||||
from itertools import ifilter, imap, izip
|
from itertools import ifilter, imap, izip
|
||||||
filter, map, zip = ifilter, imap, izip
|
filter, map, zip = ifilter, imap, izip
|
||||||
|
|
||||||
def iteritems(dikt): return dikt.iteritems() # noqa: E731
|
def iteritems(dikt):
|
||||||
|
return dikt.iteritems() # noqa: E731
|
||||||
reduce = reduce
|
reduce = reduce
|
||||||
|
@ -123,8 +123,9 @@ def new(options=None):
|
|||||||
def load(default, user=None):
|
def load(default, user=None):
|
||||||
|
|
||||||
# return set of (section, option)
|
# return set of (section, option)
|
||||||
def setify(cp): return set((section, option) for section in cp.sections()
|
def setify(cp):
|
||||||
for option in cp.options(section))
|
return set((section, option) for section in cp.sections()
|
||||||
|
for option in cp.options(section))
|
||||||
|
|
||||||
parser = new()
|
parser = new()
|
||||||
parser.read(default)
|
parser.read(default)
|
||||||
|
@ -123,7 +123,8 @@ class uWSGIMixin(Mixin):
|
|||||||
|
|
||||||
timedelta = conf.getint("moderation", "purge-after")
|
timedelta = conf.getint("moderation", "purge-after")
|
||||||
|
|
||||||
def purge(signum): return self.db.comments.purge(timedelta)
|
def purge(signum):
|
||||||
|
return self.db.comments.purge(timedelta)
|
||||||
uwsgi.register_signal(1, "", purge)
|
uwsgi.register_signal(1, "", purge)
|
||||||
uwsgi.add_timer(1, timedelta)
|
uwsgi.add_timer(1, timedelta)
|
||||||
|
|
||||||
|
@ -98,7 +98,8 @@ class SQLite3:
|
|||||||
# limit max. nesting level to 1
|
# limit max. nesting level to 1
|
||||||
if self.version == 2:
|
if self.version == 2:
|
||||||
|
|
||||||
def first(rv): return list(map(operator.itemgetter(0), rv))
|
def first(rv):
|
||||||
|
return list(map(operator.itemgetter(0), rv))
|
||||||
|
|
||||||
with sqlite3.connect(self.path) as con:
|
with sqlite3.connect(self.path) as con:
|
||||||
top = first(con.execute(
|
top = first(con.execute(
|
||||||
|
@ -37,7 +37,9 @@ class Dummy:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def curl(method, host, path): return Dummy()
|
def curl(method, host, path):
|
||||||
|
return Dummy()
|
||||||
|
|
||||||
|
|
||||||
def loads(data): return json.loads(data.decode('utf-8'))
|
def loads(data):
|
||||||
|
return json.loads(data.decode('utf-8'))
|
||||||
|
@ -119,7 +119,8 @@ class TestComments(unittest.TestCase):
|
|||||||
|
|
||||||
def testVerifyFields(self):
|
def testVerifyFields(self):
|
||||||
|
|
||||||
def verify(comment): return comments.API.verify(comment)[0]
|
def verify(comment):
|
||||||
|
return comments.API.verify(comment)[0]
|
||||||
|
|
||||||
# text is missing
|
# text is missing
|
||||||
self.assertFalse(verify({}))
|
self.assertFalse(verify({}))
|
||||||
|
@ -97,7 +97,8 @@ class TestGuard(unittest.TestCase):
|
|||||||
|
|
||||||
def testSelfReply(self):
|
def testSelfReply(self):
|
||||||
|
|
||||||
def payload(id): return json.dumps({"text": "...", "parent": id})
|
def payload(id):
|
||||||
|
return json.dumps({"text": "...", "parent": id})
|
||||||
|
|
||||||
client = self.makeClient("127.0.0.1", self_reply=False)
|
client = self.makeClient("127.0.0.1", self_reply=False)
|
||||||
self.assertEqual(client.post(
|
self.assertEqual(client.post(
|
||||||
@ -124,7 +125,8 @@ class TestGuard(unittest.TestCase):
|
|||||||
|
|
||||||
def testRequireEmail(self):
|
def testRequireEmail(self):
|
||||||
|
|
||||||
def payload(email): return json.dumps({"text": "...", "email": email})
|
def payload(email):
|
||||||
|
return json.dumps({"text": "...", "email": email})
|
||||||
|
|
||||||
client = self.makeClient("127.0.0.1", ratelimit=4, require_email=False)
|
client = self.makeClient("127.0.0.1", ratelimit=4, require_email=False)
|
||||||
client_strict = self.makeClient(
|
client_strict = self.makeClient(
|
||||||
@ -144,8 +146,8 @@ class TestGuard(unittest.TestCase):
|
|||||||
|
|
||||||
def testRequireAuthor(self):
|
def testRequireAuthor(self):
|
||||||
|
|
||||||
def payload(author): return json.dumps(
|
def payload(author):
|
||||||
{"text": "...", "author": author})
|
return json.dumps({"text": "...", "author": author})
|
||||||
|
|
||||||
client = self.makeClient(
|
client = self.makeClient(
|
||||||
"127.0.0.1", ratelimit=4, require_author=False)
|
"127.0.0.1", ratelimit=4, require_author=False)
|
||||||
|
@ -10,10 +10,10 @@ class TestWSGIUtilities(unittest.TestCase):
|
|||||||
def test_urlsplit(self):
|
def test_urlsplit(self):
|
||||||
|
|
||||||
examples = [
|
examples = [
|
||||||
("http://example.tld/", ('example.tld', 80, False)),
|
("http://example.tld/", ('example.tld', 80, False)),
|
||||||
("https://example.tld/", ('example.tld', 443, True)),
|
("https://example.tld/", ('example.tld', 443, True)),
|
||||||
("example.tld", ('example.tld', 80, False)),
|
("example.tld", ('example.tld', 80, False)),
|
||||||
("example.tld:42", ('example.tld', 42, False)),
|
("example.tld:42", ('example.tld', 42, False)),
|
||||||
("https://example.tld:80/", ('example.tld', 80, True))]
|
("https://example.tld:80/", ('example.tld', 80, True))]
|
||||||
|
|
||||||
for (hostname, result) in examples:
|
for (hostname, result) in examples:
|
||||||
@ -23,7 +23,7 @@ class TestWSGIUtilities(unittest.TestCase):
|
|||||||
|
|
||||||
examples = [
|
examples = [
|
||||||
(("example.tld", 80, False), "http://example.tld"),
|
(("example.tld", 80, False), "http://example.tld"),
|
||||||
(("example.tld", 42, True), "https://example.tld:42"),
|
(("example.tld", 42, True), "https://example.tld:42"),
|
||||||
(("example.tld", 443, True), "https://example.tld")]
|
(("example.tld", 443, True), "https://example.tld")]
|
||||||
|
|
||||||
for (split, result) in examples:
|
for (split, result) in examples:
|
||||||
|
@ -104,23 +104,23 @@ class API(object):
|
|||||||
ACCEPT = set(['text', 'author', 'website', 'email', 'parent', 'title', 'notification'])
|
ACCEPT = set(['text', 'author', 'website', 'email', 'parent', 'title', 'notification'])
|
||||||
|
|
||||||
VIEWS = [
|
VIEWS = [
|
||||||
('fetch', ('GET', '/')),
|
('fetch', ('GET', '/')),
|
||||||
('new', ('POST', '/new')),
|
('new', ('POST', '/new')),
|
||||||
('count', ('GET', '/count')),
|
('count', ('GET', '/count')),
|
||||||
('counts', ('POST', '/count')),
|
('counts', ('POST', '/count')),
|
||||||
('feed', ('GET', '/feed')),
|
('feed', ('GET', '/feed')),
|
||||||
('view', ('GET', '/id/<int:id>')),
|
('view', ('GET', '/id/<int:id>')),
|
||||||
('edit', ('PUT', '/id/<int:id>')),
|
('edit', ('PUT', '/id/<int:id>')),
|
||||||
('delete', ('DELETE', '/id/<int:id>')),
|
('delete', ('DELETE', '/id/<int:id>')),
|
||||||
('unsubscribe', ('GET', '/id/<int:id>/unsubscribe/<string:email>/<string:key>')),
|
('unsubscribe', ('GET', '/id/<int:id>/unsubscribe/<string:email>/<string:key>')),
|
||||||
('moderate', ('GET', '/id/<int:id>/<any(edit,activate,delete):action>/<string:key>')),
|
('moderate', ('GET', '/id/<int:id>/<any(edit,activate,delete):action>/<string:key>')),
|
||||||
('moderate', ('POST', '/id/<int:id>/<any(edit,activate,delete):action>/<string:key>')),
|
('moderate', ('POST', '/id/<int:id>/<any(edit,activate,delete):action>/<string:key>')),
|
||||||
('like', ('POST', '/id/<int:id>/like')),
|
('like', ('POST', '/id/<int:id>/like')),
|
||||||
('dislike', ('POST', '/id/<int:id>/dislike')),
|
('dislike', ('POST', '/id/<int:id>/dislike')),
|
||||||
('demo', ('GET', '/demo')),
|
('demo', ('GET', '/demo')),
|
||||||
('preview', ('POST', '/preview')),
|
('preview', ('POST', '/preview')),
|
||||||
('login', ('POST', '/login')),
|
('login', ('POST', '/login')),
|
||||||
('admin', ('GET', '/admin'))
|
('admin', ('GET', '/admin'))
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, isso, hasher):
|
def __init__(self, isso, hasher):
|
||||||
|
Loading…
Reference in New Issue
Block a user