diff options
author | Guido van Rossum <guido@python.org> | 1998-03-25 16:25:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-03-25 16:25:26 (GMT) |
commit | 69c70a2fd1a23739e9cb4fb7f75e76d4e56172ef (patch) | |
tree | 1ffb71bdd97fe20faa255f074f5e74546087fbe8 /Lib | |
parent | 55730316c9fb9a82331c4b56c8f9dce1b93bce05 (diff) | |
download | cpython-69c70a2fd1a23739e9cb4fb7f75e76d4e56172ef.zip cpython-69c70a2fd1a23739e9cb4fb7f75e76d4e56172ef.tar.gz cpython-69c70a2fd1a23739e9cb4fb7f75e76d4e56172ef.tar.bz2 |
Support 'whence' parameter to seek().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/multifile.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/multifile.py b/Lib/multifile.py index 71e0dd0..247b010 100644 --- a/Lib/multifile.py +++ b/Lib/multifile.py @@ -44,8 +44,17 @@ class MultiFile: return self.lastpos return self.fp.tell() - self.start # - def seek(self, pos): - if not 0 <= pos <= self.tell() or \ + def seek(self, pos, whence=0): + here = self.tell() + if whence: + if whence == 1: + pos = pos + here + elif whence == 2: + if self.level > 0: + pos = pos + self.lastpos + else: + raise Error, "can't use whence=2 yet" + if not 0 <= pos <= here or \ self.level > 0 and pos > self.lastpos: raise Error, 'bad MultiFile.seek() call' self.fp.seek(pos + self.start) |