From: Greg W. <gw...@py...> - 2002-10-29 20:57:57
|
On 29 October 2002, Barry A. Warsaw said: > Except the patch also gets rid of the multiline string, which is a > style I find more readable than multiple prints. +1 if you fix that > <wink>. Damn, I was hoping I could subtly persuade you that, for cases where the string exceeds a certain threshold of variability, multiple prints work better. (In particular, I don't like redundant "Reply-To", so I want to suppress it if -R wasn't supplied -- IMHO that makes this string variable enough.) Second attempt at the patch (unlike the last attempt, I haven't tested this one): --- syncmail 19 Sep 2002 19:30:15 -0000 1.21 +++ syncmail 29 Oct 2002 20:56:26 -0000 @@ -51,6 +51,10 @@ --subject-prefix=TEXT Prepend TEXT to the email subject line. + -R ADDR + --reply-to=ADDR + Add a "Reply-To: ADDR" header to the email message. + --quiet / -q Don't print as much status to stdout. @@ -215,7 +219,7 @@ -def blast_mail(subject, people, filestodiff, contextlines, fromhost): +def blast_mail(subject, people, filestodiff, contextlines, fromhost, replyto): # cannot wait for child process or that will cause parent to retain cvs # lock for too long. Urg! if not os.fork(): @@ -232,17 +236,21 @@ s = StringIO() sys.stdout = s try: + vars = {'address' : address, + 'name' : name, + 'people' : string.join(people, COMMASPACE), + 'subject' : subject, + 'version' : __version__, + } print '''\ From: "%(name)s" <%(address)s> -To: %(people)s +To: %(people)s''' % vars + if replyto: + print 'Reply-To: %s' % replyto + print '''\ Subject: %(subject)s X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail> -''' % {'address' : address, - 'name' : name, - 'people' : string.join(people, COMMASPACE), - 'subject' : subject, - 'version' : __version__, - } +''' % vars s.write(sys.stdin.read()) # append the diffs if available print @@ -260,8 +268,9 @@ def main(): try: opts, args = getopt.getopt( - sys.argv[1:], 'hC:cuS:qf:', - ['fromhost=', 'context=', 'cvsroot=', 'subject-prefix=', + sys.argv[1:], 'hC:cuS:R:qf:', + ['fromhost=', 'context=', 'cvsroot=', + 'subject-prefix=', 'reply-to=', 'help', 'quiet']) except getopt.error, msg: usage(1, msg) @@ -270,6 +279,7 @@ contextlines = 2 verbose = 1 subject_prefix = "" + replyto = None fromhost = None for opt, arg in opts: if opt in ('-h', '--help'): @@ -285,6 +295,8 @@ contextlines = 0 elif opt in ('-S', '--subject-prefix'): subject_prefix = arg + elif opt in ('-R', '--reply-to'): + replyto = arg elif opt in ('-q', '--quiet'): verbose = 0 elif opt in ('-f', '--fromhost'): @@ -326,7 +338,7 @@ if verbose: print 'Generating notification message...' - blast_mail(subject, people, specs[1:], contextlines, fromhost) + blast_mail(subject, people, specs[1:], contextlines, fromhost, replyto) if verbose: print 'Generating notification message... done.' -- Greg Ward <gw...@py...> http://www.gerg.ca/ I don't believe there really IS a GAS SHORTAGE.. I think it's all just a BIG HOAX on the part of the plastic sign salesmen -- to sell more numbers!! |