From: martin f. krafft Date: Sun, 30 Sep 2007 16:12:09 +0000 (+0100) Subject: create default template if none exists X-Git-Tag: mailplate-0.1~11 X-Git-Url: https://git.madduck.net/code/mailplate.git/commitdiff_plain/45ef81678284c9f8f7fad90fc9bff7f876469759 create default template if none exists --- 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