Here's a patch against tmda-address to hack in optional sender address
mapping. This patch works against both the version in CVS, and the 1.0.3
release.
This patch has the minor foible of creating sender.map in the current
working directory. I'm currently working on a patch to Defaults.py to
make the location and filename configurable.
Also, attempts to pass an optional argument to the -m flag don't seem to
work as expected in Python. I'm sure there's a Pythonic idiom for this,
but the getopt module doesn't seem to support it natively. Suggestions
welcome.
--- tmda-address 2005/01/16 18:16:00 1.14
+++ tmda-address 2005/01/16 21:41:05 1.14.1.1
@@ -59,6 +59,11 @@
Generate a dated-style tagged address. timeout is an
optional timeout interval to override your default.
See the output of tmda-pending -h for syntax of timeout.
+
+ -m
+ --map
+ Store the sender-style address and the email address used to
+ generate it into a map file for future reference.
"""
import getopt
@@ -87,14 +92,15 @@
opts = None
try:
opts, args = getopt.getopt(args,
- 'c:a:dk:s:hVn', ['config-file=',
+ 'c:a:dk:s:hVnm', ['config-file=',
'address=',
'dated',
'keyword=',
'sender=',
'help',
'version',
- 'no-newline'])
+ 'no-newline',
+ 'map'])
except getopt.error, msg:
usage(1, msg)
return (opts, args)
@@ -145,6 +151,8 @@
option = arg
elif opt in ('-n', '--no-newline'):
print_newline = 0
+ elif opt in ('-m', '--map'):
+ mapfile = open('sender.map', 'a')
opts.remove((opt, arg))
@@ -152,7 +160,7 @@
from TMDA import Address
def main():
- global address, tag, option, print_newline
+ global address, tag, option, mapfile, print_newline
try:
tagged_address = Address.Factory(tag = tag).create(address,
option).address
@@ -163,6 +171,9 @@
if not tagged_address:
usage(0)
+ if mapfile:
+ mapfile.write('%s\t%s\n' % (tagged_address, option))
+ mapfile.close()
sys.stdout.write(tagged_address)
if print_newline:
--
Find my Techno-Geek Journal at http://www.codegnome.org/geeklog/
_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers