##// END OF EJS Templates
byterange: replace uses of hasattr with getattr
Augie Fackler -
r14947:3aa34005 default
parent child Browse files
Show More
@@ -103,9 +103,7 b' class RangeableFileObject(object):'
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.
@@ -170,10 +168,8 b' class RangeableFileObject(object):'
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):
General Comments 0
You need to be logged in to leave comments. Login now