nobodd.transfer

The module implements the copy_bytes() function which does the same as shutil.copyfileobj() but operates more efficiently (in a similar manner to shutil.copyfile() which we can’t use because that expects to operate on the “real” file-system).

Functions

nobodd.transfer.copy_bytes(source, target, *, byterange=None)[source]

Copy byterange bytes (a range object), or all bytes (if byterange is None, the default) from source to target.

The target must implement a write method, and the source must at the very least implement a read method, but preferably a readinto method (which will permit a single static buffer to be used during the transfer). If byterange is not None, the source must additionally implemented seek. No attempt is made to seek the target; bytes are simply written to it at its current position.