fs.tools

Miscellaneous tools for operating on filesystems.

fs.tools.copy_file_data(src_file, dst_file, chunk_size=None)[source]

Copy data from one file object to another.

Parameters:
  • src_file (io.IOBase) – File open for reading.
  • dst_file (io.IOBase) – File open for writing.
  • chunk_size (int) – Number of bytes to copy at a time (or None to use sensible default).
fs.tools.get_intermediate_dirs(fs, dir_path)[source]

Get a list of non-existing intermediate directories.

Parameters:
  • fs (FS) – A filesystem instance.
  • dir_path (str) – A path to a new directory on the filesystem.
Returns:

A list of non-existing paths.

Return type:

list

Raises:

DirectoryExpected – If a path component references a file and not a directory.

fs.tools.is_thread_safe(*filesystems)[source]

Check if all filesystems are thread-safe.

Parameters:filesystems (FS) – Filesystems instances to check.
Returns:if all filesystems are thread safe.
Return type:bool
fs.tools.remove_empty(fs, path)[source]

Remove all empty parents.

Parameters:
  • fs (FS) – A filesystem instance.
  • path (str) – Path to a directory on the filesystem.