[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] mailer.py

From: Mathias Weinert <mathias.weinert_at_gfa-net.de>
Date: 2006-01-20 12:44:09 CET

I was trying to provide all my changes step by step in order
to a) make it easier for the commiter and b) make it easier
to handle the discussion (if there is any).

Anyway the following two (unrelated) changes will be the
last one I separated. The rest I will send in one piece as
it would be a bit difficult to split them for me (I will send
them as soon as this ones have been committed, discussed, sent
to hell or whatever ;-)

The first change allows to use another character but the default
whitespaces to separate different mail addresses in the to_addr
field. This is usefull for using additional name information
in the mail addresses. Example:

 to_addr_split_char = ,
 to_addr = "The great Wallace" <wallace@atanyaddress>, "little Grommit" <grommit@propablyatthesameaddress>

This was the simple example (which doesn't make so much sense).
A more sensible example is the following one:

 [maps]
 from_addr = [mail_addresses]
 to_addr = [mail_addresses]

 [mail_addresses]
 wallace = "The great Wallace" <wallace@atanyaddress>
 grommit = "little Grommit" <grommit@propablyatthesameaddress>

With this I at least don't use the comma as separator but don't
use the whitespaces any more and am therefor able to use one set
of mail addresses containing blanks which I use for the to_addr
as well as for the from_addr which at the end provide the commit
mails a better look in the mail clients.

I could have changed the mail address seapartor in general
from whitespaces to comma but this would lead to problems
with old configuration files.

The second change allows users to use capital letters
for map substitution names. If you use a map substitution
name with capital letters in the current release of mailer.py
(for example "Wallace" in the example above) it won't work as
all option names are converted to lower case but not the name
of the value.

So I changed this to a way that the value is also converted to
lower case and added some hints to the config examples file.

Mathias

[[[
* tools/hook-scripts/mailer/mailer.py
  - new option 'to_addr_split_char' added which allows to use another character but the default whitespaces to separate different mail addresses
  - it's now possible to use capital letters in option values which will be passed through a map

* tools/hook-scripts/mailer/mailer.conf.example
  - new option 'to_addr_split_char' added which allows to use another character but the default whitespaces to separate different mail addresses
  - added a hint to the description of the mapping process
]]]

--- tools/hook-scripts/mailer/mailer.py.new 2006-01-19 22:02:53.150000000 +0100
+++ tools/hook-scripts/mailer/mailer.py.2 2006-01-20 10:39:41.171196600 +0100
@@ -183,9 +183,15 @@
     OutputBase.__init__(self, cfg, repos, prefix_param)
 
   def start(self, group, params):
- # whitespace-separated list of addresses; split into a clean list:
- self.to_addrs = \
- filter(None, string.split(self.cfg.get('to_addr', group, params)))
+ # whitespace (or as set by to_addr_split_char)-separated list
+ # of addresses; split into a clean list:
+ if self.cfg.is_set('general.to_addr_split_char'):
+ self.to_addrs = \
+ filter(None, string.split(self.cfg.get('to_addr', group, params), \
+ self.cfg.general.to_addr_split_char))
+ else:
+ self.to_addrs = \
+ filter(None, string.split(self.cfg.get('to_addr', group, params)))
     self.from_addr = self.cfg.get('from_addr', group, params) \
                      or self.repos.author or 'no_author'
     self.reply_to = self.cfg.get('reply_to', group, params)
@@ -1109,7 +1115,8 @@
         # then just return the value unchanged.
         setattr(self.maps, optname,
                 lambda value,
- sect=getattr(self, sectname): getattr(sect, value,
+ sect=getattr(self, sectname): getattr(sect,
+ value.lower(),
                                                              value))
         # mark for removal when all optnames are done
         if sectname not in mapsections:
--- tools/hook-scripts/mailer/mailer.conf.example.new 2006-01-19 22:02:53.280000000 +0100
+++ tools/hook-scripts/mailer/mailer.conf.example.2 2006-01-20 10:35:59.913921200 +0100
@@ -27,6 +27,12 @@
 #smtp_username = example
 #smtp_password = example
 
+# If this option is set to a character this character will be used
+# to split the mail addresses given to_addr.
+# If this option is not set all whitespace characters (but no comma)
+# are used for splitting.
+#to_addr_split_char = ,
+
 # --------------------------------------------------------------------------
 
 #
@@ -167,7 +173,8 @@
 from_addr = invalid@example.com
 
 # The default To: addresses for message. One or more addresses,
-# separated by whitespace (no commas):
+# separated by whitespace (no commas) or the character set at
+# to_addr_split_char.
 to_addr = invalid@example.com
 
 # If this is set, then a Reply-To: will be inserted into the message.
@@ -242,9 +249,18 @@
 # are made here in the [maps] section.
 #
 # When an option is accessed, the value is loaded from the configuration
-# file and all %(NAME)s substitutions are performed. The resulting value
-# is then passed through the map. If a map entry is not available for
-# the value, then it will be used unchanged.
+# file and all %(NAME)s substitutions are performed. The resulting
+# value(*) is then passed through the map. If a map entry is not available
+# for the value, then it will be used unchanged(**).
+#
+# (*) In fact the value passing and comparing is done case insensitive so
+# don't use values which only differ in case.
+#
+# (**) unchanged means the original value, i. e. no case change is done.
+#
+# Please note that a colon ':' is also considered as separator between
+# option and value. For mapping of filepaths under windows see example 2
+# below.
 #
 # The format to declare a map is:
 #

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jan 20 12:45:28 2006

This is an archived mail posted to the Subversion Dev mailing list.