toil.lib.io
¶
Module Contents¶
Classes¶
A stream wrapping class that calls any functions passed to onWrite() with the number of bytes written for every write. |
Functions¶
|
Robustly tries to delete paths. |
|
Return a tmp file name to use with atomic_install. This will be in the |
|
atomic install of tmp_path as final_path |
|
Context manager to create a temporary file. Entering returns path to |
|
Copy a file using posix atomic creations semantics. |
|
Copy an open file using posix atomic creations semantics. |
|
Try to make a random directory name with length 4 that doesn't exist, with the given prefix. |
|
Try to use the given path. Return it if it exists or can be made, |
Attributes¶
- toil.lib.io.logger¶
- toil.lib.io.robust_rmtree(path)[source]¶
Robustly tries to delete paths.
Continues silently if the path to be removed is already gone, or if it goes away while this function is executing.
May raise an error if a path changes between file and directory while the function is executing, or if a permission error is encountered.
- toil.lib.io.atomic_tmp_file(final_path)[source]¶
Return a tmp file name to use with atomic_install. This will be in the same directory as final_path. The temporary file will have the same extension as finalPath. It the final path is in /dev (/dev/null, /dev/stdout), it is returned unchanged and atomic_tmp_install will do nothing.
- toil.lib.io.atomic_install(tmp_path, final_path)[source]¶
atomic install of tmp_path as final_path
- Return type
None
- toil.lib.io.AtomicFileCreate(final_path, keep=False)[source]¶
Context manager to create a temporary file. Entering returns path to the temporary file in the same directory as finalPath. If the code in context succeeds, the file renamed to its actually name. If an error occurs, the file is not installed and is removed unless keep is specified.
- toil.lib.io.atomic_copy(src_path, dest_path, executable=None)[source]¶
Copy a file using posix atomic creations semantics.
- toil.lib.io.atomic_copyobj(src_fh, dest_path, length=16384, executable=False)[source]¶
Copy an open file using posix atomic creations semantics.
- Parameters
src_fh (io.BytesIO) –
dest_path (str) –
length (int) –
executable (bool) –
- Return type
None
- toil.lib.io.make_public_dir(in_directory=None)[source]¶
Try to make a random directory name with length 4 that doesn’t exist, with the given prefix. Otherwise, try length 5, length 6, etc, up to a max of 32 (len of uuid4 with dashes replaced). This function’s purpose is mostly to avoid having long file names when generating directories. If somehow this fails, which should be incredibly unlikely, default to a normal uuid4, which was our old default.
- toil.lib.io.try_path(path)[source]¶
Try to use the given path. Return it if it exists or can be made, and we can make things within it, or None otherwise.
- class toil.lib.io.WriteWatchingStream(backingStream)[source]¶
A stream wrapping class that calls any functions passed to onWrite() with the number of bytes written for every write.
Not seekable.
- Parameters
backingStream (IO[Any]) –