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
rangeobject), or all bytes (if byterange isNone, the default) from source to target.The target must implement a
writemethod, and the source must at the very least implement areadmethod, but preferably areadintomethod (which will permit a single static buffer to be used during the transfer). If byterange is notNone, the source must additionally implementedseek. No attempt is made to seek the target; bytes are simply written to it at its current position.