trivial enhancement to tmda.

Mike Meyer <[email protected]>
Newsgroups gmane.mail.spam.tmda.devel
Message-ID <[email protected]>
It occured to me that tmda's keyword address mechanism didnt't have
anything in to prevent you from accidently giving the same address to
two different lists. In fact, I've done that.

Since such addresses are generally oneof's, a mechanism to generate a
unique - or at least highly unlikely to be repeated - address might be
usefull. It took about five minutes to generate the attached patch to
tmda-address, adding a "-u --unique" option to generate a unique
keyword addres.

I thought you might want to consider adding it.

	<mike

--- /usr/opt/bin/tmda-address	Tue Jun 28 09:16:09 2005
+++ /home/mwm/bin/tmda-address	Tue Oct 11 22:31:35 2005
@@ -49,6 +49,11 @@
 	   Generate a keyword-style tagged address.  keyword is
 	   a required keyword string.
 
+        -u
+        --unique
+           Generate a keyword-style tagged address, using a keyword
+           that you aren't likely to generate again.
+
 	-s <address>
 	--sender <address>
 	   Generate a sender-style tagged address.  address is
@@ -64,6 +69,7 @@
 import getopt
 import os
 import sys
+import time
 
 try:
     import paths
@@ -87,11 +93,12 @@
     opts = None
     try:
 	opts, args = getopt.getopt(args,
-                                   'c:a:dk:s:hVn', ['config-file=',
+                                   'c:a:dk:s:uhVn', ['config-file=',
                                                     'address=',
                                                     'dated',
                                                     'keyword=',
                                                     'sender=',
+                                                     'unique',
                                                     'help',
                                                     'version',
                                                     'no-newline'])
@@ -140,6 +147,13 @@
 	elif opt in ('-k', '--keyword'):
 	    tag = Defaults.TAGS_KEYWORD[0].lower()
 	    option = arg
+        elif opt in ('-u', '--unique'):
+            tag = Defaults.TAGS_KEYWORD[0].lower()
+            t = time.time()
+            if t == int(t):
+                option = 'unique:%d.%d' % (t, os.getpid())
+            else:
+                option = 'unique:%f' % t
 	elif opt in ('-s', '--sender'):
 	    tag = Defaults.TAGS_SENDER[0].lower()
 	    option = arg

-- 
Mike Meyer <[email protected]>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.