polymerist.genutils.fileutils.filetree

Tools for manipulating files and directories in the file system

Attributes

dir_tree

Classes

PathToNodeCorrespondence

Concrete implementation of pathlib Paths as nodes in a tree

Functions

startfile(→ None)

Replacement for os.startfile() functionality, since none natively exists in Linux

temporary_cd(→ Generator[pathlib.Path, None, None])

Context manager for temporarily changing the current working directory of code wrapped in a "with" block

clear_dir(→ None)

Recursively clear contents of a directory at the given path (depth-first)

Module Contents

class polymerist.genutils.fileutils.filetree.PathToNodeCorrespondence[source]

Bases: polymerist.genutils.trees.treebase.NodeCorrespondence

Concrete implementation of pathlib Paths as nodes in a tree

name(path: pathlib.Path) str[source]

Define how to obtain a string name

has_children(path: pathlib.Path) bool[source]

Define how to check if an object can produce children in the first place before attempting to do so

children(path) Iterable[pathlib.Path][source]

Define how to obtain node children from an instance Should return NoneType if the instance is “leaf-like”

polymerist.genutils.fileutils.filetree.dir_tree
polymerist.genutils.fileutils.filetree.startfile(path: pathlib.Path) None[source]

Replacement for os.startfile() functionality, since none natively exists in Linux

polymerist.genutils.fileutils.filetree.temporary_cd(dir_path: pathlib.Path | None) Generator[pathlib.Path, None, None][source]

Context manager for temporarily changing the current working directory of code wrapped in a “with” block

polymerist.genutils.fileutils.filetree.clear_dir(path: pathlib.Path) None[source]

Recursively clear contents of a directory at the given path (depth-first)