summaryrefslogtreecommitdiffstats
path: root/Demo/scripts
diff options
context:
space:
mode:
authorMoshe Zadka <moshez@math.huji.ac.il>2001-02-20 16:21:35 (GMT)
committerMoshe Zadka <moshez@math.huji.ac.il>2001-02-20 16:21:35 (GMT)
commit8b6f9898158462bfadf0476fd3a829bcce42fdb5 (patch)
tree9d130aac71349b76f080b00a79738820caed558a /Demo/scripts
parent38e083bcc970f49a4e3ceecea602b6491c9a58a9 (diff)
downloadcpython-8b6f9898158462bfadf0476fd3a829bcce42fdb5.zip
cpython-8b6f9898158462bfadf0476fd3a829bcce42fdb5.tar.gz
cpython-8b6f9898158462bfadf0476fd3a829bcce42fdb5.tar.bz2
Fixed to use new Python features and use more commonly accepted style
Reindented
Diffstat (limited to 'Demo/scripts')
-rwxr-xr-xDemo/scripts/from.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/Demo/scripts/from.py b/Demo/scripts/from.py
index 9f749ae..d61afde 100755
--- a/Demo/scripts/from.py
+++ b/Demo/scripts/from.py
@@ -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