From 45ef81678284c9f8f7fad90fc9bff7f876469759 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sun, 30 Sep 2007 17:12:09 +0100 Subject: [PATCH] create default template if none exists --- mailplate | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mailplate b/mailplate index e815be9..6410670 100755 --- a/mailplate +++ b/mailplate @@ -170,7 +170,7 @@ CONFFILE = os.path.expanduser(CONFFILE) MAILPLATEDIR = os.path.expanduser(MAILPLATEDIR) # defaults -config = { 'default_template' : None +config = { 'default_template' : 'default' , 'template_path' : TEMPLATEDIR } helpers = { 'get_quote' : 'fortune -s' } @@ -223,6 +223,14 @@ TPATH = os.path.expanduser(config['template_path']) if not os.path.isdir(TPATH): os.mkdir(TPATH, 0700) +default_templname = config['default_template'] +if default_templname is not None: + default_templpath = os.path.join(TPATH, default_templname) + if not os.path.isfile(default_templpath): + f = file(default_templpath, 'w') + f.write('@KEEP_STD_HEADERS\n\n@KEEP_BODY\n') + f.close() + ### ### COMMAND LINE PARSING ### @@ -304,7 +312,7 @@ else: rawmsg = ''.join(inf.readlines()) if options.auto: - best_score = (0, config['default_template'], {}) + best_score = (0, default_templname, {}) for tf in os.listdir(TPATH): tp = os.path.join(TPATH, tf) if not os.path.isfile(tp) or not os.access(tp, os.R_OK): continue -- 2.39.2