Commit 5403ac9b authored by Moshe Zadka's avatar Moshe Zadka

Fixed to use new Python features and use more commonly accepted style

Reindented
parent c35dad5a
...@@ -9,27 +9,27 @@ import sys, os ...@@ -9,27 +9,27 @@ import sys, os
# Open mailbox file. Exits with exception when this fails. # Open mailbox file. Exits with exception when this fails.
try: try:
mailbox = os.environ['MAIL'] mailbox = os.environ['MAIL']
except (AttributeError, KeyError): except (AttributeError, KeyError):
sys.stderr.write('No environment variable $MAIL\n') sys.stderr.write('No environment variable $MAIL\n')
sys.exit(2) sys.exit(2)
try: try:
mail = open(mailbox, 'r') mail = open(mailbox)
except IOError: except IOError:
sys.stderr.write('Cannot open mailbox file: ' + mailbox + '\n') sys.exit('Cannot open mailbox file: ' + mailbox)
sys.exit(2)
while 1: while 1:
line = mail.readline() line = mail.readline()
if not line: break # EOF if not line:
if line[:5] == 'From ': break # EOF
# Start of message found if line.startswith('From '):
print line[:-1], # Start of message found
while 1: print line[:-1],
line = mail.readline() while 1:
if not line: break # EOF line = mail.readline()
if line == '\n': break # Blank line ends headers if not line or line == '\n':
if line[:8] == 'Subject:': break
print `line[9:-1]`, if line.startswith('Subject: '):
print print `line[9:-1]`,
print
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment