add: CONTRIBUTORS + pep8
This commit is contained in:
parent
b21f2e4aaa
commit
94d031444d
@ -86,5 +86,8 @@ In chronological order:
|
|||||||
* @p-vitt & @M4a1x
|
* @p-vitt & @M4a1x
|
||||||
* Documentation on troubleshooting for uberspace users
|
* Documentation on troubleshooting for uberspace users
|
||||||
|
|
||||||
|
* @benjhess
|
||||||
|
* Optionnal gravatar support
|
||||||
|
|
||||||
* [Your name or handle] <[email or website]>
|
* [Your name or handle] <[email or website]>
|
||||||
* [Brief summary of your changes]
|
* [Brief summary of your changes]
|
||||||
|
@ -55,7 +55,7 @@ class Progress(object):
|
|||||||
|
|
||||||
if time() - self.last > 0.2:
|
if time() - self.last > 0.2:
|
||||||
sys.stdout.write("\r{0}".format(" " * cols))
|
sys.stdout.write("\r{0}".format(" " * cols))
|
||||||
sys.stdout.write("\r[{0:.0%}] {1}".format(i/self.end, message))
|
sys.stdout.write("\r[{0:.0%}] {1}".format(i / self.end, message))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
self.last = time()
|
self.last = time()
|
||||||
|
|
||||||
|
@ -134,13 +134,13 @@ class TestComments(unittest.TestCase):
|
|||||||
self.assertFalse(verify({"text": text}))
|
self.assertFalse(verify({"text": text}))
|
||||||
|
|
||||||
# email/website length
|
# email/website length
|
||||||
self.assertTrue(verify({"text": "...", "email": "*"*254}))
|
self.assertTrue(verify({"text": "...", "email": "*" * 254}))
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
verify({"text": "...", "website": "google.de/" + "a"*128}))
|
verify({"text": "...", "website": "google.de/" + "a" * 128}))
|
||||||
|
|
||||||
self.assertFalse(verify({"text": "...", "email": "*"*1024}))
|
self.assertFalse(verify({"text": "...", "email": "*" * 1024}))
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
verify({"text": "...", "website": "google.de/" + "*"*1024}))
|
verify({"text": "...", "website": "google.de/" + "*" * 1024}))
|
||||||
|
|
||||||
# valid website url
|
# valid website url
|
||||||
self.assertTrue(comments.isurl("example.tld"))
|
self.assertTrue(comments.isurl("example.tld"))
|
||||||
|
@ -36,7 +36,7 @@ def anonymize(remote_addr):
|
|||||||
ipv6 = ipaddress.IPv6Address(remote_addr)
|
ipv6 = ipaddress.IPv6Address(remote_addr)
|
||||||
if ipv6.ipv4_mapped is not None:
|
if ipv6.ipv4_mapped is not None:
|
||||||
return anonymize(ipv6.ipv4_mapped)
|
return anonymize(ipv6.ipv4_mapped)
|
||||||
return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000']*5)
|
return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000'] * 5)
|
||||||
except ipaddress.AddressValueError:
|
except ipaddress.AddressValueError:
|
||||||
return u'0.0.0.0'
|
return u'0.0.0.0'
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ class Bloomfilter:
|
|||||||
|
|
||||||
def add(self, key):
|
def add(self, key):
|
||||||
for i in self.get_probes(key):
|
for i in self.get_probes(key):
|
||||||
self.array[i//8] |= 2 ** (i % 8)
|
self.array[i // 8] |= 2 ** (i % 8)
|
||||||
self.elements += 1
|
self.elements += 1
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
return all(self.array[i//8] & (2 ** (i % 8)) for i in self.get_probes(key))
|
return all(self.array[i // 8] & (2 ** (i % 8)) for i in self.get_probes(key))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return self.elements
|
return self.elements
|
||||||
|
@ -732,6 +732,7 @@ class API(object):
|
|||||||
comment['replies'] = self._process_fetched_list(replies, plain)
|
comment['replies'] = self._process_fetched_list(replies, plain)
|
||||||
|
|
||||||
return JSON(rv, 200)
|
return JSON(rv, 200)
|
||||||
|
|
||||||
def _add_gravatar_image(self, item):
|
def _add_gravatar_image(self, item):
|
||||||
if not self.conf.getboolean('gravatar'):
|
if not self.conf.getboolean('gravatar'):
|
||||||
return item
|
return item
|
||||||
@ -743,6 +744,7 @@ class API(object):
|
|||||||
item['gravatar_image'] = gravatar_url.format(email_md5_hash)
|
item['gravatar_image'] = gravatar_url.format(email_md5_hash)
|
||||||
|
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def _process_fetched_list(self, fetched_list, plain=False):
|
def _process_fetched_list(self, fetched_list, plain=False):
|
||||||
for item in fetched_list:
|
for item in fetched_list:
|
||||||
|
|
||||||
@ -851,7 +853,6 @@ class API(object):
|
|||||||
@apiSuccessExample Counts of 5 threads:
|
@apiSuccessExample Counts of 5 threads:
|
||||||
[2, 18, 4, 0, 3]
|
[2, 18, 4, 0, 3]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def counts(self, environ, request):
|
def counts(self, environ, request):
|
||||||
|
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
|
@ -30,7 +30,7 @@ def host(environ): # pragma: no cover
|
|||||||
of http://www.python.org/dev/peps/pep-0333/#url-reconstruction
|
of http://www.python.org/dev/peps/pep-0333/#url-reconstruction
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = environ['wsgi.url_scheme']+'://'
|
url = environ['wsgi.url_scheme'] + '://'
|
||||||
|
|
||||||
if environ.get('HTTP_HOST'):
|
if environ.get('HTTP_HOST'):
|
||||||
url += environ['HTTP_HOST']
|
url += environ['HTTP_HOST']
|
||||||
|
Loading…
Reference in New Issue
Block a user