From 64054ec02907c660ef27b4c6e78d3856a00aab71 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 28 May 2014 11:05:10 +0200 Subject: [PATCH] remove unused code, fix pyflakes and jshint hints --- docs/conf.py | 1 - isso/js/app/config.js | 5 +++-- isso/js/app/count.js | 2 +- isso/js/app/lib/promise.js | 6 +++--- isso/js/count.js | 2 +- isso/js/lib/requirejs-jade/jade.js | 2 +- isso/tests/test_comments.py | 2 +- isso/tests/test_db.py | 2 +- isso/utils/__init__.py | 5 ----- isso/utils/html.py | 1 - 10 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0da47e1..773a796 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,6 @@ import pkg_resources dist = pkg_resources.get_distribution("isso") import sys -import os from os.path import join, dirname sys.path.insert(0, join(dirname(__file__), "_isso/")) diff --git a/isso/js/app/config.js b/isso/js/app/config.js index ce51250..043cdb4 100644 --- a/isso/js/app/config.js +++ b/isso/js/app/config.js @@ -17,7 +17,8 @@ define(function() { var js = document.getElementsByTagName("script"); for (var i = 0; i < js.length; i++) { - [].forEach.call(js[i].attributes, function(attr) { + for (var j = 0; j < js[i].attributes.length; j++) { + var attr = js[i].attributes[j]; if (/^data-isso-/.test(attr.name)) { try { config[attr.name.substring(10)] = JSON.parse(attr.value); @@ -25,7 +26,7 @@ define(function() { config[attr.name.substring(10)] = attr.value; } } - }); + } } // split avatar-fg on whitespace diff --git a/isso/js/app/count.js b/isso/js/app/count.js index 7b795fd..a1fff4b 100644 --- a/isso/js/app/count.js +++ b/isso/js/app/count.js @@ -4,7 +4,7 @@ define(["app/api", "app/dom", "app/i18n"], function(api, $, i18n) { var objs = {}; $.each("a", function(el) { - if (! el.href.match("#isso-thread$")) { + if (! el.href.match(/#isso-thread$/)) { return; } diff --git a/isso/js/app/lib/promise.js b/isso/js/app/lib/promise.js index 4f23be9..d947b4c 100644 --- a/isso/js/app/lib/promise.js +++ b/isso/js/app/lib/promise.js @@ -18,11 +18,11 @@ define(function() { } }; - var defer = function() { + var Defer = function() { this.promise = new Promise(); }; - defer.prototype = { + Defer.prototype = { promise: Promise, resolve: function(rv) { this.promise.success.forEach(function(callback) { @@ -50,7 +50,7 @@ define(function() { }; return { - defer: function() { return new defer(); }, + defer: function() { return new Defer(); }, when: when }; diff --git a/isso/js/count.js b/isso/js/count.js index e9f2236..7b7b305 100644 --- a/isso/js/count.js +++ b/isso/js/count.js @@ -1,5 +1,5 @@ require(["app/lib/ready", "app/count"], function(domready, count) { domready(function() { count(); - }) + }); }); diff --git a/isso/js/lib/requirejs-jade/jade.js b/isso/js/lib/requirejs-jade/jade.js index b26ad55..59189a4 100644 --- a/isso/js/lib/requirejs-jade/jade.js +++ b/isso/js/lib/requirejs-jade/jade.js @@ -10,7 +10,7 @@ define(function() { if (typeof process !== "undefined") { var fs = require.nodeRequire("fs"); - var jade = require.nodeRequire("jade"); + jade = require.nodeRequire("jade"); fetchText = function(path, callback) { callback(fs.readFileSync(path, "utf-8")); }; diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index 9975bcb..e1dc38a 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -353,7 +353,7 @@ class TestComments(unittest.TestCase): def testDeleteCommentRemovesThread(self): - rv = self.client.post('/new?uri=%2F', data=json.dumps({"text": "..."})) + self.client.post('/new?uri=%2F', data=json.dumps({"text": "..."})) self.assertIn('/', self.app.db.threads) self.client.delete('/id/1') self.assertNotIn('/', self.app.db.threads) diff --git a/isso/tests/test_db.py b/isso/tests/test_db.py index b69de81..b5276f5 100644 --- a/isso/tests/test_db.py +++ b/isso/tests/test_db.py @@ -89,7 +89,7 @@ class TestDBMigration(unittest.TestCase): "VALUEs (?, ?, ?)", (id, parent, id)) conf = Config.load(None) - db = SQLite3(self.path, conf) + SQLite3(self.path, conf) flattened = [ (1, None), diff --git a/isso/utils/__init__.py b/isso/utils/__init__.py index 36896ec..9a50a79 100644 --- a/isso/utils/__init__.py +++ b/isso/utils/__init__.py @@ -8,11 +8,6 @@ werkzeug = pkg_resources.get_distribution("werkzeug") import json import hashlib -try: - from html.parser import HTMLParser, HTMLParseError -except ImportError: - from HTMLParser import HTMLParser, HTMLParseError - from werkzeug.wrappers import Request, Response from werkzeug.exceptions import BadRequest diff --git a/isso/utils/html.py b/isso/utils/html.py index 5650bfd..212875d 100644 --- a/isso/utils/html.py +++ b/isso/utils/html.py @@ -10,7 +10,6 @@ html5lib_version = pkg_resources.get_distribution("html5lib").version from html5lib.sanitizer import HTMLSanitizer from html5lib.serializer import HTMLSerializer -from html5lib.treewalkers import getTreeWalker import misaka