summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-04-18 17:21:41 +0300
committerLars Wirzenius <liw@liw.fi>2015-04-18 17:21:41 +0300
commit54fd1c2268c82014baf54ee5c97201a43e728723 (patch)
tree58b75541c6d6adc25559a356523ae5f1b74ae921
parent27be49a8d1d7d236a0fa5878552f34adc238352f (diff)
downloadjt-54fd1c2268c82014baf54ee5c97201a43e728723.tar.gz
Run pylint in ./check; fix problems found
-rwxr-xr-xcheck1
-rwxr-xr-xjt35
-rw-r--r--pylint.conf28
3 files changed, 45 insertions, 19 deletions
diff --git a/check b/check
index b9312b3..340be5a 100755
--- a/check
+++ b/check
@@ -21,5 +21,6 @@ set -eu
pep8 jt
+pylint --rcfile=pylint.conf jt
yarn -s yarns/yarn.sh yarns/*.yarn "$@"
copyright-statement-lint jt
diff --git a/jt b/jt
index 0006484..defeabd 100755
--- a/jt
+++ b/jt
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright 2010-2014 Lars Wirzenius
+# Copyright 2010-2015 Lars Wirzenius
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,16 +16,11 @@
import cliapp
-import optparse
import os
import re
import shutil
import string
-import subprocess
-import sys
-import tempfile
import time
-import traceback
__version__ = '0.5'
@@ -58,8 +53,7 @@ class DraftsDirectory(object):
pathname = self.get_draft_pathname(i)
if not os.path.exists(pathname):
return i
- else:
- raise cliapp.AppException('ERROR: too many existing drafts')
+ raise cliapp.AppException('ERROR: too many existing drafts')
def get_drafts(self):
for basename in os.listdir(self.dirname):
@@ -82,7 +76,7 @@ class DraftsDirectory(object):
with open(pathname) as f:
for line in f:
m = re.match(
- '\[\[!meta title="(?P<title>.*)("\]\])$',
+ r'\[\[!meta title="(?P<title>.*)("\]\])$',
line)
if m:
title = m.group('title')
@@ -157,7 +151,7 @@ class ListCommand(Command):
def run(self, args):
drafts_dir = DraftsDirectory(self._app.drafts_dir())
- for draft_id, filename in drafts_dir.get_drafts():
+ for draft_id, _ in drafts_dir.get_drafts():
print draft_id, drafts_dir.get_draft_title(draft_id)
@@ -167,7 +161,7 @@ class EditCommand(Command):
if len(args) > 1:
raise cliapp.AppException('Must be given at most one draft ID')
drafts_dir = DraftsDirectory(self._app.drafts_dir())
- draft_id, pathname = self._app.choose_draft(drafts_dir, args)
+ _, pathname = self._app.choose_draft(drafts_dir, args)
self._app.edit_file(pathname)
@@ -310,16 +304,19 @@ class NewPersonCommand(Command):
if os.path.exists(pathname):
raise cliapp.AppException('File %s already exists' % pathname)
- with open(pathname, 'w') as f:
- f.write('''\
+ template = '''\
[[!meta title="%(name)s"]]
[[!inline archive=yes pages="link(.)"]]
-''' %
- {
- 'name': name,
- 'basename': basename,
- })
+'''
+
+ with open(pathname, 'w') as f:
+ f.write(
+ template %
+ {
+ 'name': name,
+ 'basename': basename,
+ })
class JournalTool(cliapp.Application):
@@ -419,7 +416,7 @@ class JournalTool(cliapp.Application):
def edit_file(self, pathname):
safe_pathname = cliapp.shell_quote(pathname)
- cmdline = ['sh', '-c', self.settings['editor'] % pathname]
+ cmdline = ['sh', '-c', self.settings['editor'] % safe_pathname]
self.runcmd(cmdline, stdin=None, stdout=None, stderr=None)
def choose_draft(self, drafts_dir, args):
diff --git a/pylint.conf b/pylint.conf
new file mode 100644
index 0000000..b36b2aa
--- /dev/null
+++ b/pylint.conf
@@ -0,0 +1,28 @@
+[MASTER]
+persistent=no
+
+[MESSAGES CONTROL]
+disable=
+ attribute-defined-outside-init,
+ bad-builtin,
+ blacklisted-name,
+ cyclic-import,
+ invalid-name,
+ missing-docstring,
+ no-self-use,
+ protected-access,
+ star-args,
+ too-few-public-methods,
+ too-many-arguments,
+ too-many-branches,
+ too-many-instance-attributes,
+ too-many-locals,
+ too-many-public-methods,
+ too-many-statements,
+ unused-argument
+
+[REPORTS]
+reports=no
+
+[SIMILARITIES]
+min-similarity-lines=999