]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added providence mailer support
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 30 Oct 1995 10:23:10 +0000 (10:23 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 30 Oct 1995 10:23:10 +0000 (10:23 +0000)
Tools/scripts/mailerdaemon.py

index 1240ff4e141fc8db22347e3b00b3ad8b561d7c8e..075df1f1f65791fc34b7778302fb03c1cff9713c 100755 (executable)
@@ -156,9 +156,41 @@ def emparse_compuserve(fp):
        errors.append(line)
     return errors
 
+prov_pattern = regex.compile('.* | \(.*\)')
 
+def emparse_providence(fp):
+    while 1:
+       line = fp.readline()
+       if not line:
+           raise Unparseable
+       line = line[:-1]
+
+       # Check that we're not in the returned message yet
+       if string.lower(line)[:5] == 'from:':
+           raise Unparseable
+       exp = 'The following errors occurred'
+       if line[:len(exp)] == exp:
+           break
+
+    errors = []
+    while 1:
+       line = fp.readline()
+       if not line:
+           break
+       line = line[:-1]
+       if not line:
+           continue
+       if line[:4] == '----':
+           break
+       if prov_pattern.match(line) > 0:
+           errors.append(prov_pattern.group(1))
+
+    if not errors:
+       raise Unparseable
+    return errors
 
-EMPARSERS = [emparse_sendmail, emparse_aol, emparse_cts, emparse_compuserve]
+EMPARSERS = [emparse_sendmail, emparse_aol, emparse_cts, emparse_compuserve,
+            emparse_providence]
 
 def parsedir(dir, modify):
     os.chdir(dir)