diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2014-12-22 02:40:39 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2014-12-22 02:40:39 +0100 |
commit | 45552a9cb1ac5433fd2010d1736b41a3393b9b6b (patch) | |
tree | 8e0e54e73deced9b3604c59b7f417d3592d9180d /news2mail.py | |
parent | 5b25c51d3a02d49db2c7e33f9b65fad5432219f4 (diff) | |
download | pygn-45552a9cb1ac5433fd2010d1736b41a3393b9b6b.tar.gz |
pygm2n and mail2news also use email.Parser.
Diffstat (limited to 'news2mail.py')
-rw-r--r-- | news2mail.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/news2mail.py b/news2mail.py index 4dd83fc..e1909a1 100644 --- a/news2mail.py +++ b/news2mail.py @@ -23,6 +23,9 @@ normal (what pygs does) operations flow is: """ import email +import logging +from collections import OrderedDict +# logging.basicConfig(level=logging.DEBUG) import sys import smtplib import time @@ -58,7 +61,6 @@ class news2mail(object): @staticmethod def puthead(from_dict, out_list, key): """private, x-form dict entries in out_list entries""" - if key in from_dict: out_list.append(key + ' ' + from_dict.get(key)) else: @@ -76,24 +78,26 @@ class news2mail(object): self.puthead(self.heads_dict, self.headers, k) for k in self.heads_dict.keys(): - if k[:2] != 'X-' and k[:7] != 'Resent-' and k not in header_set: + if not k.startswith('X-') and not k.startswith('Resent-') \ + and k not in header_set: self.puthead(self.heads_dict, self.headers, k) for k in self.heads_dict.keys(): - if k[:2] == 'X-': + if k.startswith('X-'): self.puthead(self.heads_dict, self.headers, k) for k in self.heads_dict.keys(): - if k[:7] == 'Resent-': + if k.startswith('Resent-'): self.puthead(self.heads_dict, self.headers, k) + logging.debug('self.headers = %s', self.headers) return self.headers def mergeheads(self): """make a unique headers dictionary from NNTP and SMTP single headers dictionaries.""" - self.heads_dict = {} + self.heads_dict = OrderedDict() try: for header in self.nntpheads.keys(): # fill it w/ nntp old heads |