summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-07-26 15:36:19 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-07-26 15:36:19 (GMT)
commit1ce7b17165c405a0772fb49c3b7143aa6b9ce4cd (patch)
tree5e0f69b0b95943c70313ac7a253be0ae76bfd034
parentcab106cfca99aab5094e344308c8c5ad3bab2167 (diff)
downloadcpython-1ce7b17165c405a0772fb49c3b7143aa6b9ce4cd.zip
cpython-1ce7b17165c405a0772fb49c3b7143aa6b9ce4cd.tar.gz
cpython-1ce7b17165c405a0772fb49c3b7143aa6b9ce4cd.tar.bz2
Fix string exception and a few style issues in mailerdaemon script
-rw-r--r--Tools/scripts/mailerdaemon.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/Tools/scripts/mailerdaemon.py b/Tools/scripts/mailerdaemon.py
index 4934b92..62189f1 100644
--- a/Tools/scripts/mailerdaemon.py
+++ b/Tools/scripts/mailerdaemon.py
@@ -1,4 +1,4 @@
-"""mailerdaemon - classes to parse mailer-daemon messages"""
+"""Classes to parse mailer-daemon messages."""
import calendar
import email.message
@@ -6,7 +6,10 @@ import re
import os
import sys
-Unparseable = 'mailerdaemon.Unparseable'
+
+class Unparseable(Exception):
+ pass
+
class ErrorMessage(email.message.Message):
def __init__(self):
@@ -18,8 +21,10 @@ class ErrorMessage(email.message.Message):
if not sub:
return 0
sub = sub.lower()
- if sub.startswith('waiting mail'): return 1
- if 'warning' in sub: return 1
+ if sub.startswith('waiting mail'):
+ return 1
+ if 'warning' in sub:
+ return 1
self.sub = sub
return 0
@@ -145,14 +150,17 @@ def emparse_list(fp, sub):
errors.append(' '.join((email.strip()+': '+reason).split()))
return errors
-EMPARSERS = [emparse_list, ]
+EMPARSERS = [emparse_list]
def sort_numeric(a, b):
a = int(a)
b = int(b)
- if a < b: return -1
- elif a > b: return 1
- else: return 0
+ if a < b:
+ return -1
+ elif a > b:
+ return 1
+ else:
+ return 0
def parsedir(dir, modify):
os.chdir(dir)