diff options
Diffstat (limited to 'jt')
-rwxr-xr-x | jt | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -1,16 +1,16 @@ #!/usr/bin/python # Copyright 2010-2014 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 # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. @@ -65,7 +65,9 @@ class DraftsDirectory(object): for basename in os.listdir(self.dirname): # .# is what Emacs autosave files start with. if basename.endswith('.mdwn') and not basename.startswith('.#'): - yield basename[:-len('.mdwn')], os.path.join(self.dirname, basename) + suffixless = basename[:-len('.mdwn')] + pathname = os.path.join(self.dirname, basename) + yield suffixless, pathname def remove_draft(self, draft_id): filename = self.get_draft_pathname(draft_id) @@ -278,13 +280,13 @@ class NewTopicCommand(Command): if not os.path.exists(dirname): os.makedirs(dirname) - with open(pathname, 'w') as f: - f.write('''\ + template = '''\ [[!meta title="%(title)s"]] [[!inline pages="link(.)" archive=yes reverse=yes trail=yes]] -''' % { - 'title': title, -}) +''' + + with open(pathname, 'w') as f: + f.write(template % {'title': title}) class NewPersonCommand(Command): @@ -315,8 +317,8 @@ class NewPersonCommand(Command): [[!inline archive=yes pages="link(.)"]] ''' % { - 'name': name, - 'basename': basename, + 'name': name, + 'basename': basename, }) @@ -369,7 +371,7 @@ class JournalTool(cliapp.Application): def process_args(self, args): if self.settings['pretend-time']: - self.now_tuple = time.strptime( + self.now_tuple = time.strptime( self.settings['pretend-time'], '%Y-%m-%d %H:%M:%S') else: self.now_tuple = time.localtime() @@ -429,7 +431,8 @@ class JournalTool(cliapp.Application): elif len(drafts) == 0: raise cliapp.AppException('No drafts to choose from') else: - raise cliapp.AppException('Cannot choose entry draft automatically') + raise cliapp.AppException( + 'Cannot choose entry draft automatically') elif len(args) == 1: pathname = drafts_dir.get_draft_pathname(args[0]) if not os.path.exists(pathname): |