pybool_ir.util#
Utility functions for pybool_ir.
Functions
|
Helper function that downloads a file from a URL and shows a progress bar. |
Classes
|
This class opens a file for reading or writing, and when it is read or written to, it updates a progress bar to show how far along the reading or writing is. |
- class pybool_ir.util.ProgressFile(filename, mode='r', max_value=None)#
Bases:
BufferedRWPair
This class opens a file for reading or writing, and when it is read or written to, it updates a progress bar to show how far along the reading or writing is.
- close() None #
Flush and close the IO object.
This method has no effect if the file is already closed.
- read(size=None)#
Read and return up to n bytes.
If the argument is omitted, None, or negative, reads and returns all data until EOF.
If the argument is positive, and the underlying raw stream is not ‘interactive’, multiple raw reads may be issued to satisfy the byte count (unless EOF is reached first). But for interactive raw streams (as well as sockets and pipes), at most one raw read will be issued, and a short result does not imply that EOF is imminent.
Returns an empty bytes object on EOF.
Returns None if the underlying raw stream was open in non-blocking mode and no data is available at the moment.
- write(b: bytes | bytearray) int #
Write the given buffer to the IO stream.
Returns the number of bytes written, which is always the length of b in bytes.
Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.
- pybool_ir.util.download_file(url: str, download_to: Path)#
Helper function that downloads a file from a URL and shows a progress bar.