]> granicus.if.org Git - python/commitdiff
Fix string exception and a few style issues in mailerdaemon script
authorÉric Araujo <merwok@netwok.org>
Tue, 26 Jul 2011 15:36:19 +0000 (17:36 +0200)
committerÉric Araujo <merwok@netwok.org>
Tue, 26 Jul 2011 15:36:19 +0000 (17:36 +0200)
Tools/scripts/mailerdaemon.py

index 4934b92eaae33837dfaa395d93d5efd581b1d6dd..62189f14e9869a124ce42f1e216b27fa12f9e69c 100644 (file)
@@ -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)