fs.tools

A collection of functions that operate on filesystems and tools.

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

Copy data from one file object to another.

Parameters:
  • src_file (file-like) – File open for reading.
  • dst_file (file-like) – 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 paths of intermediate directories required to create a new directory.

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

A list of paths.

Return type:

list

Raises:

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

fs.tools.remove_empty(fs, path)[source]

Remove all empty parents.

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