summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-10-03 10:37:20 +0300
committerLars Wirzenius <liw@liw.fi>2015-10-03 10:37:20 +0300
commit2039e7b1065d21db4a614f29b26cb81f0ab98944 (patch)
treecca299126176316b29adfc4e8c754a580e9893ce
parent6b00e6cc829602cec7e6b6b73f94febd28bfa9a3 (diff)
downloadjt-2039e7b1065d21db4a614f29b26cb81f0ab98944.tar.gz
Add --templates setting
-rw-r--r--jtlib/app.py14
1 files 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()