diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 576f9cb..10537ff 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -86,5 +86,8 @@ In chronological order: * @p-vitt & @M4a1x * Documentation on troubleshooting for uberspace users +* @benjhess + * Optionnal gravatar support + * [Your name or handle] <[email or website]> * [Brief summary of your changes] diff --git a/isso/migrate.py b/isso/migrate.py index f6297b7..2296e3c 100644 --- a/isso/migrate.py +++ b/isso/migrate.py @@ -55,7 +55,7 @@ class Progress(object): if time() - self.last > 0.2: 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() self.last = time() diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index a4ae5a5..fa32039 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -134,13 +134,13 @@ class TestComments(unittest.TestCase): self.assertFalse(verify({"text": text})) # email/website length - self.assertTrue(verify({"text": "...", "email": "*"*254})) + self.assertTrue(verify({"text": "...", "email": "*" * 254})) 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( - verify({"text": "...", "website": "google.de/" + "*"*1024})) + verify({"text": "...", "website": "google.de/" + "*" * 1024})) # valid website url self.assertTrue(comments.isurl("example.tld")) diff --git a/isso/utils/__init__.py b/isso/utils/__init__.py index 254aab1..ed925a9 100644 --- a/isso/utils/__init__.py +++ b/isso/utils/__init__.py @@ -36,7 +36,7 @@ def anonymize(remote_addr): ipv6 = ipaddress.IPv6Address(remote_addr) if ipv6.ipv4_mapped is not None: 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: return u'0.0.0.0' @@ -89,11 +89,11 @@ class Bloomfilter: def add(self, 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 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): return self.elements diff --git a/isso/utils/hash.py b/isso/utils/hash.py index d964036..93a084e 100644 --- a/isso/utils/hash.py +++ b/isso/utils/hash.py @@ -110,4 +110,4 @@ def new(conf): sha1 = Hash(func="sha1").uhash -md5 = Hash(func="md5").uhash \ No newline at end of file +md5 = Hash(func="md5").uhash diff --git a/isso/views/comments.py b/isso/views/comments.py index a6f39fc..b76be46 100644 --- a/isso/views/comments.py +++ b/isso/views/comments.py @@ -732,6 +732,7 @@ class API(object): comment['replies'] = self._process_fetched_list(replies, plain) return JSON(rv, 200) + def _add_gravatar_image(self, item): if not self.conf.getboolean('gravatar'): return item @@ -743,6 +744,7 @@ class API(object): item['gravatar_image'] = gravatar_url.format(email_md5_hash) return item + def _process_fetched_list(self, fetched_list, plain=False): for item in fetched_list: @@ -851,7 +853,6 @@ class API(object): @apiSuccessExample Counts of 5 threads: [2, 18, 4, 0, 3] """ - def counts(self, environ, request): data = request.get_json() diff --git a/isso/wsgi.py b/isso/wsgi.py index 60c1a58..864d017 100644 --- a/isso/wsgi.py +++ b/isso/wsgi.py @@ -30,7 +30,7 @@ def host(environ): # pragma: no cover 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'): url += environ['HTTP_HOST']