]> granicus.if.org Git - python/commitdiff
Fixed to use new Python features and use more commonly accepted style
authorMoshe Zadka <moshez@math.huji.ac.il>
Tue, 20 Feb 2001 16:21:35 +0000 (16:21 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Tue, 20 Feb 2001 16:21:35 +0000 (16:21 +0000)
Reindented

Demo/scripts/from.py

index 9f749aea60ec855c2e817213bec384bf8b64cc2e..d61afde06e4b9a45a3bf5e4013f21c512c54adc9 100755 (executable)
@@ -9,27 +9,27 @@ import sys, os
 # Open mailbox file.  Exits with exception when this fails.
 
 try:
-       mailbox = os.environ['MAIL']
+    mailbox = os.environ['MAIL']
 except (AttributeError, KeyError):
-       sys.stderr.write('No environment variable $MAIL\n')
-       sys.exit(2)
+    sys.stderr.write('No environment variable $MAIL\n')
+    sys.exit(2)
 
 try:
-       mail = open(mailbox, 'r')
+    mail = open(mailbox)
 except IOError:
-       sys.stderr.write('Cannot open mailbox file: ' + mailbox + '\n')
-       sys.exit(2)
+    sys.exit('Cannot open mailbox file: ' + mailbox)
 
 while 1:
-       line = mail.readline()
-       if not line: break # EOF
-       if line[:5] == 'From ':
-               # Start of message found
-               print line[:-1],
-               while 1:
-                       line = mail.readline()
-                       if not line: break # EOF
-                       if line == '\n': break # Blank line ends headers
-                       if line[:8] == 'Subject:':
-                               print `line[9:-1]`,
-               print
+    line = mail.readline()
+    if not line:
+        break # EOF
+    if line.startswith('From '):
+        # Start of message found
+        print line[:-1],
+        while 1:
+            line = mail.readline()
+            if not line or line == '\n':
+                break
+            if line.startswith('Subject: '):
+                print `line[9:-1]`,
+        print