diff options
author | Georg Brandl <georg@python.org> | 2010-12-30 17:22:33 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-12-30 17:22:33 (GMT) |
commit | 4cf83f4d128bd40ebe3b6e59ced4895f554d18de (patch) | |
tree | ccc6e4c3e03a711c45f4badf811314231d646d95 /Demo/scripts/from.py | |
parent | d1fc34d563a9fd06a78226b1bb4e56286c70e035 (diff) | |
download | cpython-4cf83f4d128bd40ebe3b6e59ced4895f554d18de.zip cpython-4cf83f4d128bd40ebe3b6e59ced4895f554d18de.tar.gz cpython-4cf83f4d128bd40ebe3b6e59ced4895f554d18de.tar.bz2 |
Remove some of the old demos. (Put a few somewhere else.)
Diffstat (limited to 'Demo/scripts/from.py')
-rwxr-xr-x | Demo/scripts/from.py | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/Demo/scripts/from.py b/Demo/scripts/from.py deleted file mode 100755 index c8a9346..0000000 --- a/Demo/scripts/from.py +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/env python3 - -# Print From and Subject of messages in $MAIL. -# Extension to multiple mailboxes and other bells & whistles are left -# as exercises for the reader. - -import sys, os - -# Open mailbox file. Exits with exception when this fails. - -try: - mailbox = os.environ['MAIL'] -except (AttributeError, KeyError): - sys.stderr.write('No environment variable $MAIL\n') - sys.exit(2) - -try: - mail = open(mailbox) -except IOError: - sys.exit('Cannot open mailbox file: ' + mailbox) - -while 1: - line = mail.readline() - if not line: - break # EOF - if line.startswith('From '): - # Start of message found - print(line[:-1], end=' ') - while 1: - line = mail.readline() - if not line or line == '\n': - break - if line.startswith('Subject: '): - print(repr(line[9:-1]), end=' ') - print() |