From 2039e7b1065d21db4a614f29b26cb81f0ab98944 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 3 Oct 2015 10:37:20 +0300 Subject: Add --templates setting --- jtlib/app.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jtlib/app.py b/jtlib/app.py index 8e0303a..4b0c54e 100644 --- a/jtlib/app.py +++ b/jtlib/app.py @@ -49,6 +49,11 @@ class JournalTool(cliapp.Application): 'new entry belongs to TOPIC', metavar='TOPIC') + self.settings.string_list( + ['templates'], + 'look for templates also in DIR', + metavar='DIR') + self.settings.string( ['new-note-template'], 'use FILE as the template for new journal notes', @@ -95,6 +100,9 @@ class JournalTool(cliapp.Application): raise cliapp.AppException('Must give at most one draft number') def read_template(self, basename): - filename = os.path.join(self.app_directory(), 'templates', basename) - with open(filename) as f: - return f.read() + default = os.path.join(self.app_directory(), 'templates') + for dirname in self.settings['templates'] + [default]: + filename = os.path.join(dirname, basename) + if os.path.exists(filename): + with open(filename) as f: + return f.read() -- cgit v1.2.1