blob: d7d049f9348eae442b2583b86bc9e20d279cdcee (
plain) (
tree)
|
|
diff --git b/mail2news.py a/mail2news.py
index e7cbcf9..412e4ee 100644
--- b/mail2news.py
+++ a/mail2news.py
@@ -24,80 +28,41 @@ import pyginfo
class mail2news:
"""news to mail gateway class"""
-
reader = None # mode reader
-# newsgroups = None # Newsgroups: local.test,local.moderated...
-# approved = None # Approved: kame@aragorn.lorien.org
newsserver = 'localhost' # no comment :)
port = 119
user = None
password = None
+# """phase 3:
+# format rfc 822 headers from input article
+# """
+#
+# m2n.mergeheads() # make unique dict from NNTP and SMTP dicts
+#
+# m2n.addheads() # add some important heads
+# m2n.renameheads() # rename useless heads
+# m2n.removeheads() # remove other heads
+#
+# m2n.sortheads() # sort remaining heads :)
+#
+# if opt.verbose:
+# for line in m2n.headers:
+# print line[:-1]
@@ -142,14 +108,11 @@ class mail2news:
self.heads_dict = {}
- try:
- for header in self.smtpheads.keys(): # fill it w/ smtp old heads
- self.heads_dict[header] = self.smtpheads[header]
-
- # and replace them w/ nntp new heads
- for header in self.nntpheads.keys():
- self.heads_dict[header] = self.nntpheads[header]
+ # FIXME something like a = set() ; a = self.message.items() ?
+ try:
+ for header in self.message.keys(): # fill it w/ smtp old heads
+ self.heads_dict[header] = self.message[header]
except KeyError, message:
print message
@@ -236,51 +166,32 @@ class mail2news:
def removeheads(self, heads=None):
"""remove headers like Xref: Path: Lines:
"""
-
- try:
# removing some others useless headers .... (From is not From:)
rmheads = ['Received:', 'From', 'NNTP-Posting-Host:',
'X-Trace:', 'X-Compliants-To:', 'NNTP-Posting-Date:']
- if(heads):
+ if heads:
rmheads.append(heads)
for head in rmheads:
- if head in self.heads_dict:
- del self.heads_dict[head]
-
-# if 'From' in self.heads_dict: # neither 'From ' nor 'From:'
-# del self.heads_dict['From']
-
-# # neither 'From ' nor 'From:'
-# if 'NNTP-Posting-Host:' in self.heads_dict:
-# del self.heads_dict['']
-
-# if 'Lines:' in self.heads_dict:
-# del self.heads_dict['Lines:']
+ if head in self.message:
+ del self.message[head]
- # it is usually set by INN, if ng is moderated...
-# if 'Sender:' in self.heads_dict:
-# del self.heads_dict['Sender:']
-
- if 'Message-id:' in self.heads_dict:
+ # FIXME the following lines are buggy, because they don't expect
+ # the header 'Message-Id' being already present
+ if 'Message-id:' in self.message:
self.heads_dict['Message-Id:'] = self.heads_dict['Message-id:']
del(self.heads_dict['Message-id:'])
- if 'Message-ID:' in self.heads_dict:
+ if 'Message-ID:' in self.message:
self.heads_dict['Message-Id:'] = self.heads_dict['Message-ID:']
del(self.heads_dict['Message-ID:'])
# If message-id is not present, I generate it
- if 'Message-Id:' not in self.heads_dict:
+ if 'Message-Id:' not in self.message:
msgid = '<pyg.%d@tuchailepuppapera.org>\n' % (getpid())
self.heads_dict['Message-Id:'] = msgid
- except KeyError, message:
- print message
-
- return self.heads_dict
-
def sendemail(self):
"""Talk to NNTP server and try to send email."""
try:
|