diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2014-12-22 00:26:30 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2014-12-22 00:46:41 +0100 |
commit | 5b25c51d3a02d49db2c7e33f9b65fad5432219f4 (patch) | |
tree | 6e8231c81e84d4b6873cb45c78a24a2a4d31074c /mail2news.py | |
parent | d3b3442e6bd72e3ba91cceb5c94e5e222b61af3a (diff) | |
download | pygn-5b25c51d3a02d49db2c7e33f9b65fad5432219f4.tar.gz |
pygn2m and news2mail.py use stdlib email parser.
Instead of doing it on their own (poorly).
Diffstat (limited to 'mail2news.py')
-rw-r--r-- | mail2news.py | 56 |
1 files changed, 4 insertions, 52 deletions
diff --git a/mail2news.py b/mail2news.py index e7cbcf9..0b97b92 100644 --- a/mail2news.py +++ b/mail2news.py @@ -18,6 +18,7 @@ import sys from os import getpid from socket import gethostbyaddr, gethostname from re import findall +from news2mail import news2mail import nntplib import pyginfo @@ -99,17 +100,9 @@ class mail2news: return self.smtpheads, self.body - def puthead(self, dict, list, key): - """private, transform dict entries in list entries - Appends key of dict to list, deleting it from dict. - """ - - if key in dict: - list.append(key + ' ' + dict.get(key)) - del dict[key] - else: - return 0 - return 1 + @staticmethod + def puthead(*args, **kwargs): + news2mail.puthead(*args, **kwargs) def sortheads(self): """make list sorted by heads: From: To: Subject: first, @@ -165,13 +158,6 @@ class mail2news: self.heads_dict['X-Gateway:'] = info.PROGNAME + ' ' + \ info.PROGDESC + ' - Mail to News\n' -# it is nntpheads stuff -# if(self.newsgroups): -# self.heads_dict['Newsgroups:'] = self.newsgroups - -# if(self.approved): -# self.heads_dict['Approved:'] = self.approved - except KeyError, message: print message @@ -185,22 +171,6 @@ class mail2news: """ try: -### test -# if(post): -# if(post in self.heads_dict): -# self.heads_dict['X-Original-' + post] = self.heads_dict[post] -# -# self.heads_dict[post] = self.heads_dict[pre] -# del(self.heads_dict[pre]) -# -# else: -# if(pre[0:2] == 'X-' and pre in self.heads_dict): -# self.heads_dict['X-Original-' + pre] = self.heads_dict[pre] -# elif(not pre[0:2] == 'X-' and 'X-' + pre in self.heads_dict): -# self.heads_dict['X-' + pre] = self.heads_dict[pre] -# del(self.heads_dict[pre]) -### end test - for key in self.heads_dict.keys(): if(key[:7] in ['Resent-']): if ('X-' + key) in self.heads_dict: @@ -224,10 +194,6 @@ class mail2news: if(ref and len(ref)): self.heads_dict['References:'] = '%s\n' % ref[0] -# if('To:' in self.heads_dict): -# self.heads_dict['X-To:'] = self.heads_dict['To:'] -# del self.heads_dict['To:'] - except KeyError, message: print message @@ -249,20 +215,6 @@ class mail2news: 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:'] - - # 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: self.heads_dict['Message-Id:'] = self.heads_dict['Message-id:'] del(self.heads_dict['Message-id:']) |