drawer#
Example#
You can use Path’s example for reference.
API#
Provides a few missing pieces for file management.
- libjam.drawer.copy_with_progress(src, dst, progress_callback: callable)#
Copies the given file while providing current progress.
- libjam.drawer.copy_tree_with_progress(src, dst, progress_callback: callable)#
Copies the given directory while providing current progress.
- libjam.drawer.unlink_tree_with_progress(directory, progress_callback: callable)#
Deletes the given directory while providing current progress.
- libjam.drawer.get_tree_size(directory) int#
Returns the size of the given directory in bytes.
- libjam.drawer.to_readable_size(size: int, ndigits: int = 1) tuple[float, str, str]#
Given a number of bytes, returns a human readable filesize, as a tuple.
Tuple format: (value, short unit name, long unit name) Example output: (6.9, ‘MB’, ‘MegaBytes’)
- libjam.drawer.start(*args) int#
Like xdg-open, but platform-aware.
- libjam.drawer.pack_zip(src, dst)#
Packs the given directory to a zip file.
- libjam.drawer.pack_zip_with_progress(src, dst, progress_callback: callable)#
Packs the given directory to a zip file while providing the current progress.
- libjam.drawer.unpack_zip(src, dst)#
Unpacks the given zip archive to the specified directory.
- libjam.drawer.unpack_zip_with_progress(src, dst, progress_callback: callable)#
Unpacks the given zip archive to the specified directory while providing current progress.
- libjam.drawer.pack_7z(src, dst)#
Packs the given directory to a 7zip file.
- libjam.drawer.unpack_7z(src, dst)#
Unpacks the given 7zip archive to the specified directory.
- libjam.drawer.unpack_7z_with_progress(src, dst, progress_callback: callable)#
Unpacks the given tar archive to the specified directory while providing current progress.
- libjam.drawer.unpack_rar(src, dst)#
Unpacks the given rar archive to the specified directory.
- libjam.drawer.unpack_rar_with_progress(src, dst, progress_callback: callable)#
Unpacks the given tar archive to the specified directory while providing current progress.
- libjam.drawer.can_unpack(archive) bool#
Checks if the given archive can be unpacked.
- libjam.drawer.unpack(src, dst)#
Unpacks the given archive to the specified directory.
If the archive type is not supported
NotImplementedErroris raised.
- libjam.drawer.unpack_with_progress(src, dst, progress_callback: callable)#
Unpacks the given archive to the specified directory while providing current progress.
If the archive type is not supported
NotImplementedErroris raised.