def emulate_seek(fd, offset, chunk=CHUNK):
    """ Emulates a seek on an object that does not support it

    The seek is emulated by reading and discarding bytes until specified offset
    is reached.

    The ``offset`` argument is in bytes from start of file. The ``chunk``
    argument can be used to adjust the size of the chunks in which read
    operation is performed. Larger chunks will reach the offset in less reads
    and cost less CPU but use more memory. Conversely, smaller chunks will be
    more memory efficient, but cause more read operations and more CPU usage.

    If chunk is set to None, then the ``offset`` amount of bytes is read at
    once. This is fastest but depending on the offset size, may use a lot of
    memory.

    Default chunk size is controlled by the ``fsend.rangewrapper.CHUNK``
    constant, which is 8KB by default.

    This function has no return value.
    """
    while chunk and offset > CHUNK:
        fd.read(chunk)
        offset -= chunk
    fd.read(offset)
def emulate_seek ( fd , offset , chunk = CHUNK ) : while chunk and offset > CHUNK : fd . read ( chunk ) offset -= chunk fd . read ( offset )
Emulates a seek on an object that does not support it

    The seek is emulated by reading and discarding bytes until specified offset
    is reached.

    The ``offset`` argument is in bytes from start of file. The ``chunk``
    argument can be used to adjust the size of the chunks in which read
    operation is performed. Larger chunks will reach the offset in less reads
    and cost less CPU but use more memory. Conversely, smaller chunks will be
    more memory efficient, but cause more read operations and more CPU usage.

    If chunk is set to None, then the ``offset`` amount of bytes is read at
    once. This is fastest but depending on the offset size, may use a lot of
    memory.

    Default chunk size is controlled by the ``fsend.rangewrapper.CHUNK``
    constant, which is 8KB by default.

    This function has no return value.