mercurial/byterange.py
changeset 14947 3aa34005a73d
parent 14764 a7d5816087a9
child 15782 7de7630053cb
equal deleted inserted replaced
14946:28762bf809d8 14947:3aa34005a73d
   101 
   101 
   102     def __getattr__(self, name):
   102     def __getattr__(self, name):
   103         """This effectively allows us to wrap at the instance level.
   103         """This effectively allows us to wrap at the instance level.
   104         Any attribute not found in _this_ object will be searched for
   104         Any attribute not found in _this_ object will be searched for
   105         in self.fo.  This includes methods."""
   105         in self.fo.  This includes methods."""
   106         if hasattr(self.fo, name):
   106         return getattr(self.fo, name)
   107             return getattr(self.fo, name)
       
   108         raise AttributeError(name)
       
   109 
   107 
   110     def tell(self):
   108     def tell(self):
   111         """Return the position within the range.
   109         """Return the position within the range.
   112         This is different from fo.seek in that position 0 is the
   110         This is different from fo.seek in that position 0 is the
   113         first byte position of the range tuple. For example, if
   111         first byte position of the range tuple. For example, if
   168     def _do_seek(self, offset):
   166     def _do_seek(self, offset):
   169         """Seek based on whether wrapped object supports seek().
   167         """Seek based on whether wrapped object supports seek().
   170         offset is relative to the current position (self.realpos).
   168         offset is relative to the current position (self.realpos).
   171         """
   169         """
   172         assert offset >= 0
   170         assert offset >= 0
   173         if not hasattr(self.fo, 'seek'):
   171         seek = getattr(self.fo, 'seek', self._poor_mans_seek)
   174             self._poor_mans_seek(offset)
   172         seek(self.realpos + offset)
   175         else:
       
   176             self.fo.seek(self.realpos + offset)
       
   177         self.realpos += offset
   173         self.realpos += offset
   178 
   174 
   179     def _poor_mans_seek(self, offset):
   175     def _poor_mans_seek(self, offset):
   180         """Seek by calling the wrapped file objects read() method.
   176         """Seek by calling the wrapped file objects read() method.
   181         This is used for file like objects that do not have native
   177         This is used for file like objects that do not have native