diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-04-18 17:21:41 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-04-18 17:21:41 +0300 |
commit | 54fd1c2268c82014baf54ee5c97201a43e728723 (patch) | |
tree | 58b75541c6d6adc25559a356523ae5f1b74ae921 /jt | |
parent | 27be49a8d1d7d236a0fa5878552f34adc238352f (diff) | |
download | jt-54fd1c2268c82014baf54ee5c97201a43e728723.tar.gz |
Run pylint in ./check; fix problems found
Diffstat (limited to 'jt')
-rwxr-xr-x | jt | 35 |
1 files changed, 16 insertions, 19 deletions
@@ -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): |