utils module contains a collection of useful utility functions. Note that they are not
imported into the namespace of
plumbum directly, and you have to explicitly import them, e.g.
from plumbum.path.utils import copy.
copy(src, dst)- Copies
srcis a directory). The arguments can be either local or remote paths – the function will sort out all the necessary details.
If both paths are local, the files are copied locally
If one path is local and the other is remote, the function uploads/downloads the files
If both paths refer to the same remote machine, the function copies the files locally on the remote machine
If both paths refer to different remote machines, the function downloads the files to a temporary location and then uploads them to the destination
move(src, dst)- Moves
dst. The arguments can be either local or remote – the function will sort our all the necessary details (as in
delete(*paths)- Deletes the given sequence of paths; each path may be a string, a local/remote path object, or an iterable of paths. If any of the paths does not exist, the function silently ignores the error and continues. For example
from plumbum.path.utils import delete delete(local.cwd // "*/*.pyc", local.cwd // "*/__pycache__")
gui_open(path)- Opens a file in the default editor on Windows, Mac, or Linux. Uses os.startfile if available (Windows), xdg_open (GNU), or open (Mac).