From 52b3df8247561fa138b273efd18e7f03a54880ef Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 21 Dec 2014 22:18:48 +0100 Subject: switch to argparse in pygn2m and cleanup in pygn2m, news2mail.py (and some leftovers in pygm2n) --- mail2news.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mail2news.py') diff --git a/mail2news.py b/mail2news.py index 3011a4e..e7cbcf9 100644 --- a/mail2news.py +++ b/mail2news.py @@ -14,11 +14,9 @@ Gets news email and sends it via SMTP. class mail2news is hopefully conform to rfc850. """ - import sys from os import getpid from socket import gethostbyaddr, gethostname -import string from re import findall import nntplib import pyginfo @@ -79,14 +77,14 @@ class mail2news: # if it is a multi-line header like Received: if line[0] not in [' ', '\t']: try: - head, value = string.split(line, ' ', 1) - except string.index_error: + head, value = line.split(' ', 1) + except ValueError: value = '' self.smtpheads[head] = value else: self.smtpheads[head] = '%s%s' % \ (self.smtpheads[head], line) - except (string.index_error), message: + except (ValueError), message: print('line: %s' % line) print('(probably missing couple "Header: value" in %s)' % line) @@ -95,7 +93,7 @@ class mail2news: elif len(line) > 0 and body: self.body.append(line) - except (string.index_error), message: + except (ValueError), message: print message sys.exit(1) -- cgit