]> git.madduck.net Git - code/mailplate.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

create default template if none exists
authormartin f. krafft <madduck@madduck.net>
Sun, 30 Sep 2007 16:12:09 +0000 (17:12 +0100)
committermartin f. krafft <madduck@madduck.net>
Sun, 30 Sep 2007 16:12:09 +0000 (17:12 +0100)
mailplate

index e815be92aefe6a5c08594fda8706ae2dae6a0215..6410670f73dd4833424578f3d3343bf0896a5336 100755 (executable)
--- 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