changeset 18:1cef0e5f5851

add -m for .sig
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Mon, 20 Jul 2020 11:21:30 +0100
parents 6c9e371b0325
children 535e3327ed1b
files mailer.py
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mailer.py	Wed Mar 25 19:21:38 2020 +0000
+++ b/mailer.py	Mon Jul 20 11:21:30 2020 +0100
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 '''Attempt at flexible mailout functionality
-Usage: mailer.py [-n] [-s] [-C cc string] [-c COLSPEC[,COLSPEC]*] [-B bcc string] [-b COLSPEC[,COLSPEC]*] [-S col[,col]*] [-a COLSPEC[,COLSPEC]*] [-p COLPAT]* [-SA file[,file]*] [-R reply-to] COLSPEC[,COLSPEC]* subject {addr-file|-} body-file
+Usage: mailer.py [-n] [-s] [-C cc string] [-c COLSPEC[,COLSPEC]*] [-B bcc string] [-b COLSPEC[,COLSPEC]*] [-S col[,col]*] [-a COLSPEC[,COLSPEC]*] [-p COLPAT]* [-SA file[,file]*] [-R reply-to] [-m .sigfilename] COLSPEC[,COLSPEC]* subject {addr-file|-} body-file
 
 Sends the body as a message from me with subject to destinations per
 lines in the addr-file selected by COLSPECs (to:) or -c/-b COLSPECs (Cc:/Bcc:)
@@ -18,6 +18,7 @@
 -S for columns to substitute as such
 -p for augmentation pattern for a column
 -R for replyTo address
+-m for .sig file, None for none
 
 COLSPEC is of the form a[:n[:f[:g]]] selects from addr-file, which must be tsv
   a gives the column for an email address
@@ -249,6 +250,7 @@
 
 dryrun=False
 replyTo=None
+sigfile=None
 
 sys.argv.pop(0)
 doSub=False
@@ -328,6 +330,12 @@
       replyTo=sys.argv.pop(0)
     else:
       usage('reply to')
+  elif sys.argv[0]=='-m':
+    sys.argv.pop(0)
+    if sys.argv:
+      sigfile=sys.argv.pop(0)
+    else:
+      usage('sig file name')
   elif sys.argv[0][0]=='-':
     print sys.argv
     usage()
@@ -367,11 +375,16 @@
 else:
   usage('body')
 
-try:
-  sig=open("/home/ht/.signature","r")
-  signature=sig.read().rstrip()
-except:
-  signature=None
+signature=None
+if sigfile!='None':
+  if sigfile is None:
+    sigfile="/home/ht/.signature"
+  try:
+    sig=open(sigfile,"r")
+    signature=sig.read().rstrip()
+  except:
+    if sigfile!="/home/ht/.signature":
+      raise
 
 CS=', '
 body=bodyFile.read().rstrip()