summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-12 12:40:48 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-12 12:40:48 (GMT)
commitee248110428d523f7e73a4918508ad48d91a36d2 (patch)
tree64391d57f47e75825a8003d6635346afad400851 /Demo
parent7f49b7a1a46df219fdbb070375fc7066edd8c016 (diff)
downloadcpython-ee248110428d523f7e73a4918508ad48d91a36d2.zip
cpython-ee248110428d523f7e73a4918508ad48d91a36d2.tar.gz
cpython-ee248110428d523f7e73a4918508ad48d91a36d2.tar.bz2
Invent Message-ID header if none is present
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/scripts/mboxconvert.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Demo/scripts/mboxconvert.py b/Demo/scripts/mboxconvert.py
index ff7ca6a..ecd6965 100755
--- a/Demo/scripts/mboxconvert.py
+++ b/Demo/scripts/mboxconvert.py
@@ -76,6 +76,8 @@ def mmdf(f):
'Bad line in MMFD mailbox: %s\n' % `line`)
return sts
+counter = 0 # for generating unique Message-ID headers
+
def message(f, delimiter = ''):
sts = 0
# Parse RFC822 header
@@ -93,6 +95,14 @@ def message(f, delimiter = ''):
# Copy RFC822 header
for line in m.headers:
print line,
+ # Invent Message-ID header if none is present
+ if not m.has_key('message-id'):
+ global counter
+ counter = counter + 1
+ msgid = "<%s.%d>" % (hex(t), counter)
+ sys.stderr.write("Adding Message-ID %s (From %s)\n" %
+ (msgid, email))
+ print "Message-ID:", msgid
print
# Copy body
while 1: