toil.lib.directory

Attributes

TOIL_DIR_URI_SCHEME

DirectoryContents

Functions

check_directory_dict_invariants(contents)

Make sure a directory structure dict makes sense. Throws an error

decode_directory(dir_path)

Decode a directory from a "toildir:" path to a directory (or a file in it).

encode_directory(contents[, name, source])

Encode a directory from a "toildir:" path to a directory (or a file in it).

directory_item_exists(dir_path)

Checks that a URL to a Toil directory or thing in it actually exists.

get_directory_contents_item(contents, remaining_path)

Get a subdirectory or file from a decoded directory and remaining path.

get_directory_item(dir_path)

Get a subdirectory or file from a URL pointing to or into a toildir: directory.

directory_contents_items(contents)

Yield each file or directory under the given contents, including itself.

directory_items(dir_path)

Yield each file or directory under the given path, including itself.

Module Contents

toil.lib.directory.TOIL_DIR_URI_SCHEME = 'toildir:'
toil.lib.directory.DirectoryContents
toil.lib.directory.check_directory_dict_invariants(contents)[source]

Make sure a directory structure dict makes sense. Throws an error otherwise.

Currently just checks to make sure no empty-string keys exist.

Parameters:

contents (DirectoryContents)

Return type:

None

toil.lib.directory.decode_directory(dir_path)[source]

Decode a directory from a “toildir:” path to a directory (or a file in it).

Returns:

the decoded directory dict, the remaining part of the path (which may be None), an identifier string for the directory (which is the stored name URI if one was provided), and the name URI and source task info.

Parameters:

dir_path (str)

Return type:

tuple[DirectoryContents, str | None, str, str | None, str | None]

toil.lib.directory.encode_directory(contents, name=None, source=None)[source]

Encode a directory from a “toildir:” path to a directory (or a file in it).

Parameters:
  • contents (DirectoryContents) – the directory dict, which is a dict from name to URI for a file or dict for a subdirectory.

  • name (str | None) – the path or URI the directory belongs at, including its basename. May not be empty if set.

  • source (str | None) – the name of a workflow component that uploaded the directory. May not be empty if set.

Return type:

str

toil.lib.directory.directory_item_exists(dir_path)[source]

Checks that a URL to a Toil directory or thing in it actually exists.

Assumes that all the pointed-to URLs exist; just checks tha tthe thing is actually in the encoded directory structure.

Parameters:

dir_path (str)

Return type:

bool

toil.lib.directory.get_directory_contents_item(contents, remaining_path)[source]

Get a subdirectory or file from a decoded directory and remaining path.

Parameters:
  • contents (DirectoryContents)

  • remaining_path (str | None)

Return type:

DirectoryContents | str

toil.lib.directory.get_directory_item(dir_path)[source]

Get a subdirectory or file from a URL pointing to or into a toildir: directory.

Parameters:

dir_path (str)

Return type:

DirectoryContents | str

toil.lib.directory.directory_contents_items(contents)[source]

Yield each file or directory under the given contents, including itself.

Yields parent items before children.

Yields each item as a str path from the root (possibly empty), and either a

str value for files or a None for directories.

The path won’t have trailing slashes.

Parameters:

contents (DirectoryContents)

Return type:

collections.abc.Iterator[tuple[str, str | None]]

toil.lib.directory.directory_items(dir_path)[source]

Yield each file or directory under the given path, including itself.

Yields parent items before children.

Yields each item as a str path from the root (possibly empty), and either a

str value for files or a None for directories.

The path won’t have trailing slashes.

Parameters:

dir_path (str)

Return type:

collections.abc.Iterator[tuple[str, str | None]]