diff --git a/docs/conf.py b/docs/conf.py index 0d0c005..e819dde 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,7 @@ except pkg_resources.DistributionNotFound: dist = type("I'm a Version", (object, ), {}) with io.open(join(dirname(__file__), "../setup.py")) as fp: for line in fp: - m = re.match("\s*version='([^']+)'\s*", line) + m = re.match("\\s*version='([^']+)'\\s*", line) if m: dist.version = m.group(1) break diff --git a/docs/releasing.rst b/docs/releasing.rst new file mode 100644 index 0000000..838b425 --- /dev/null +++ b/docs/releasing.rst @@ -0,0 +1,5 @@ +Releasing steps +=============== + +* Run ``make check``, ``python3 setup.py nosetests``, ``python2 setup.py nosetests`` +* Update version number in ``setup.py`` and ``CHANGES.rst`` diff --git a/isso/config.py b/isso/config.py index 488224b..917641d 100644 --- a/isso/config.py +++ b/isso/config.py @@ -38,7 +38,7 @@ def timedelta(string): """ keys = ["weeks", "days", "hours", "minutes", "seconds"] - regex = "".join(["((?P<%s>\d+)%s ?)?" % (k, k[0]) for k in keys]) + regex = "".join(["((?P<%s>\\d+)%s ?)?" % (k, k[0]) for k in keys]) kwargs = {} for k, v in re.match(regex, string).groupdict(default="0").items(): kwargs[k] = int(v) diff --git a/isso/db/comments.py b/isso/db/comments.py index 7a44efd..f9575b2 100644 --- a/isso/db/comments.py +++ b/isso/db/comments.py @@ -37,7 +37,7 @@ class Comments: ' notification INTEGER DEFAULT 0);']) try: self.db.execute(['ALTER TABLE comments ADD COLUMN notification INTEGER DEFAULT 0;']) - except: + except Exception: pass def add(self, uri, c): @@ -137,8 +137,7 @@ class Comments: for f in fields_comments]) sql_threads_fields = ', '.join(['threads.' + f for f in fields_threads]) - sql = ['SELECT ' + sql_comments_fields + ', ' + - sql_threads_fields + ' ' + sql = ['SELECT ' + sql_comments_fields + ', ' + sql_threads_fields + ' ' 'FROM comments INNER JOIN threads ' 'ON comments.tid=threads.id ' 'WHERE comments.mode = ? '] diff --git a/isso/ext/notifications.py b/isso/ext/notifications.py index 0bf1ac1..7d62d72 100644 --- a/isso/ext/notifications.py +++ b/isso/ext/notifications.py @@ -69,6 +69,7 @@ class SMTPConnection(object): def __exit__(self, exc_type, exc_value, traceback): self.client.quit() + class SMTP(object): def __init__(self, isso): @@ -165,7 +166,7 @@ class SMTP(object): for comment_to_notify in comments_to_notify: email = comment_to_notify["email"] if "email" in comment_to_notify and comment_to_notify["notification"] and email not in notified \ - and comment_to_notify["id"] != comment["id"] and email != comment["email"]: + and comment_to_notify["id"] != comment["id"] and email != comment["email"]: body = self.format(thread, comment, parent_comment, email, admin=False) subject = "Re: New comment posted on %s" % thread["title"] self.sendmail(subject, body, thread, comment, to=email) diff --git a/isso/migrate.py b/isso/migrate.py index b63af58..c32a63c 100644 --- a/isso/migrate.py +++ b/isso/migrate.py @@ -248,7 +248,7 @@ class WordPress(object): @classmethod def detect(cls, peek): - return re.compile("http://wordpress.org/export/(1\.\d)/").search(peek) + return re.compile("http://wordpress.org/export/(1\\.\\d)/").search(peek) class Generic(object): diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index fa32039..3c13b43 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -352,7 +352,7 @@ class TestComments(unittest.TestCase): self.assertEqual(rv.status_code, 200) self.assertEqual(rv.headers['ETag'], '"1-2"') data = rv.data.decode('utf-8') - data = re.sub('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+Z', + data = re.sub('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]+Z', '2018-04-01T10:00:00Z', data) self.assertEqual(data, """ 2018-04-01T10:00:00Ztag:example.org,2018:/isso/thread/path/Comments for example.org/path/tag:example.org,2018:/isso/1/2Comment #22018-04-01T10:00:00Z<p><em>Second</em></p>tag:example.org,2018:/isso/1/1Comment #12018-04-01T10:00:00Z<p>First</p>""") diff --git a/isso/utils/hash.py b/isso/utils/hash.py index 93a084e..4c23217 100644 --- a/isso/utils/hash.py +++ b/isso/utils/hash.py @@ -16,7 +16,7 @@ except ImportError: def pbkdf2(val, salt, iterations, dklen, func): return _pbkdf2(val, salt, iterations, dklen, ("hmac-" + func).encode("utf-8")) except ImportError as ex: - raise ImportError("No PBKDF2 implementation found. Either upgrade " + + raise ImportError("No PBKDF2 implementation found. Either upgrade " "to `werkzeug` 0.9 or install `passlib`.") diff --git a/isso/utils/html.py b/isso/utils/html.py index fcbe521..0cb4a80 100644 --- a/isso/utils/html.py +++ b/isso/utils/html.py @@ -15,19 +15,16 @@ class Sanitizer(object): # # [1] https://github.com/vmg/sundown/blob/master/html/html.c self.elements = ["a", "p", "hr", "br", "ol", "ul", "li", - "pre", "code", "blockquote", - "del", "ins", "strong", "em", - "h1", "h2", "h3", "h4", "h5", "h6", - "table", "thead", "tbody", "th", "td"] + elements + "pre", "code", "blockquote", + "del", "ins", "strong", "em", + "h1", "h2", "h3", "h4", "h5", "h6", + "table", "thead", "tbody", "th", "td"] + elements # href for and align for self.attributes = ["align", "href"] + attributes - - def sanitize(self, text): - clean_html = bleach.clean(text, tags=self.elements, - attributes=self.attributes, strip=True) + clean_html = bleach.clean(text, tags=self.elements, attributes=self.attributes, strip=True) def set_links(attrs, new=False): href_key = (None, u'href') diff --git a/isso/views/comments.py b/isso/views/comments.py index 8d292f4..269dd6b 100644 --- a/isso/views/comments.py +++ b/isso/views/comments.py @@ -1066,7 +1066,7 @@ class API(object): get_current_url(env, strip_querystring=True) + '/index.html' ) - def login(self, env, req): + def login(self, env, req): data = req.form password = self.isso.conf.get("general", "admin_password") if data['password'] and data['password'] == password: @@ -1091,9 +1091,9 @@ class API(object): data = self.isso.unsign(req.cookies.get('admin-session', ''), max_age=60 * 60 * 24) except BadSignature: - return render_template('login.html',isso_host_script=isso_host_script) + return render_template('login.html', isso_host_script=isso_host_script) if not data or not data['logged']: - return render_template('login.html',isso_host_script=isso_host_script) + return render_template('login.html', isso_host_script=isso_host_script) page_size = 100 page = int(req.args.get('page', 0)) order_by = req.args.get('order_by', None)