fs.tools

Miscellaneous tools for operating on filesystems.

fs.tools.copy_file_data(src_file: IO, dst_file: IO, chunk_size: Optional[int] = None)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: FS, dir_path: Text)List[Text][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: FS)bool[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: FS, path: Text)None[source]

Remove all empty parents.

Parameters
  • fs (FS) – A filesystem instance.

  • path (str) – Path to a directory on the filesystem.