def truncate(self, size=None):
"""
Resize the stream to the given size in bytes (or the current position
if size is not specified). This resizing can extend or reduce the
current file size. The new file size is returned.
In prior versions of picamera, truncation also changed the position of
the stream (because prior versions of these stream classes were
non-seekable). This functionality is now deprecated; scripts should
use :meth:`~io.IOBase.seek` and :meth:`truncate` as one would with
regular :class:`~io.BytesIO` instances.
"""
if size is not None:
warnings.warn(
PiCameraDeprecated(
'This method changes the position of the stream to the '
'truncated length; this is deprecated functionality and '
'you should not rely on it (seek before or after truncate '
'to ensure position is consistent)'))
super(PiArrayOutput, self).truncate(size)
if size is not None:
self.seek(size)
评论列表
文章目录