OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The encoded stream file-like object implementation.""" | 2 """The encoded stream file-like object implementation.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import os | 6 import os |
7 | 7 |
8 from dfvfs.encoding import manager as encoding_manager | 8 from dfvfs.encoding import manager as encoding_manager |
9 from dfvfs.file_io import file_io | 9 from dfvfs.file_io import file_io |
10 from dfvfs.lib import errors | 10 from dfvfs.lib import errors |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 if decoded_stream_size < 0: | 195 if decoded_stream_size < 0: |
196 raise ValueError(( | 196 raise ValueError(( |
197 'Invalid decoded stream size: {0:d} value out of ' | 197 'Invalid decoded stream size: {0:d} value out of ' |
198 'bounds.').format(decoded_stream_size)) | 198 'bounds.').format(decoded_stream_size)) |
199 | 199 |
200 self._decoded_stream_size = decoded_stream_size | 200 self._decoded_stream_size = decoded_stream_size |
201 | 201 |
202 # Note: that the following functions do not follow the style guide | 202 # Note: that the following functions do not follow the style guide |
203 # because they are part of the file-like object interface. | 203 # because they are part of the file-like object interface. |
| 204 # pylint: disable=invalid-name |
204 | 205 |
205 def read(self, size=None): | 206 def read(self, size=None): |
206 """Reads a byte string from the file-like object at the current offset. | 207 """Reads a byte string from the file-like object at the current offset. |
207 | 208 |
208 The function will read a byte string of the specified size or | 209 The function will read a byte string of the specified size or |
209 all of the remaining data if no size was specified. | 210 all of the remaining data if no size was specified. |
210 | 211 |
211 Args: | 212 Args: |
212 size (Optional[int]): number of bytes to read, where None is all | 213 size (Optional[int]): number of bytes to read, where None is all |
213 remaining data. | 214 remaining data. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 Raises: | 345 Raises: |
345 IOError: if the file-like object has not been opened. | 346 IOError: if the file-like object has not been opened. |
346 """ | 347 """ |
347 if not self._is_open: | 348 if not self._is_open: |
348 raise IOError('Not opened.') | 349 raise IOError('Not opened.') |
349 | 350 |
350 if self._decoded_stream_size is None: | 351 if self._decoded_stream_size is None: |
351 self._decoded_stream_size = self._GetDecodedStreamSize() | 352 self._decoded_stream_size = self._GetDecodedStreamSize() |
352 | 353 |
353 return self._decoded_stream_size | 354 return self._decoded_stream_size |
OLD | NEW |