diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 08:17:42 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 08:17:42 (GMT) |
commit | df24153f650f39ca82db143cc4a58062412a0896 (patch) | |
tree | ef25511e9b65ed1ef05a0848ef456d4e728f565f /Lib/tarfile.py | |
parent | 8ed338ab44daf3cd681d73156fd1d9b6bed53795 (diff) | |
download | cpython-df24153f650f39ca82db143cc4a58062412a0896.zip cpython-df24153f650f39ca82db143cc4a58062412a0896.tar.gz cpython-df24153f650f39ca82db143cc4a58062412a0896.tar.bz2 |
Patch #1107973: tarfile.ExFileObject iterators.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 9d00615..9bfad25 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -616,6 +616,22 @@ class ExFileObject(object): """Close the file object. """ self.closed = True + + def __iter__(self): + """Get an iterator over the file object. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + return self + + def next(self): + """Get the next item from the file iterator. + """ + result = self.readline() + if not result: + raise StopIteration + return result + #class ExFileObject #------------------ |