diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2011-10-01 20:49:36 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-27 13:27:51 +0000 |
commit | 921ced43c48c1d170452a7b251b94cc96ec8dd44 (patch) | |
tree | 3c4a89176ea67fe4c7bf7b375488361a823c95fa /mercurial/byterange.py | |
parent | 9039c805b0a7e36220101323f82735f08a104b37 (diff) | |
download | mercurial-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/mercurial-tarball/mercurial-1.9.3.tar.gz.HEADmercurial-1.9.3master
Diffstat (limited to 'mercurial/byterange.py')
-rw-r--r-- | mercurial/byterange.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mercurial/byterange.py b/mercurial/byterange.py index f4f5f53..cc8f893 100644 --- a/mercurial/byterange.py +++ b/mercurial/byterange.py @@ -9,8 +9,10 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, see -# <http://www.gnu.org/licenses/>. +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA # This file is part of urlgrabber, a high-level cross-protocol url-grabber # Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko @@ -101,7 +103,9 @@ class RangeableFileObject(object): """This effectively allows us to wrap at the instance level. Any attribute not found in _this_ object will be searched for in self.fo. This includes methods.""" - return getattr(self.fo, name) + if hasattr(self.fo, name): + return getattr(self.fo, name) + raise AttributeError(name) def tell(self): """Return the position within the range. @@ -166,8 +170,10 @@ class RangeableFileObject(object): offset is relative to the current position (self.realpos). """ assert offset >= 0 - seek = getattr(self.fo, 'seek', self._poor_mans_seek) - seek(self.realpos + offset) + if not hasattr(self.fo, 'seek'): + self._poor_mans_seek(offset) + else: + self.fo.seek(self.realpos + offset) self.realpos += offset def _poor_mans_seek(self, offset): |