Skip to main content

Module fsutil

Module fsutil 

Source
Expand description

os.path / glob behaviours the commands lean on.

FunctionsΒ§

abspath
os.path.abspath: absolute and lexically normalised (. and .. collapsed, trailing slash dropped). Symlinks are not resolved.
basename
os.path.basename
glob_children
sorted(glob.glob(os.path.join(dir, f"{prefix}*{suffix}"))) β€” direct children only, sorted by full path, dotfiles excluded like glob does.
glob_recursive
sorted(glob.glob(str(root / "**" / f"{prefix}*{suffix}"), recursive=True)) β€” every depth, sorted by full path, hidden directories and files skipped.
list_dir_raw
Directory entries in raw readdir order β€” what os.listdir, os.scandir and glob.glob return. Some Python code never sorts, so neither can the port.
name_matches πŸ”’
pathlib_glob
sorted(Path(dir).glob(f"{prefix}*{suffix}")) β€” pathlib’s glob, which unlike the glob module does match dotfiles.
pathlib_rglob_contains
sorted(Path(dir).rglob(f"*{infix}*{suffix}")) β€” every depth, dotfiles and hidden directories included, filename must contain infix and end with suffix.
relpath
os.path.relpath(path, start) for two absolute paths: . when equal, .. segments when path is not under start.
sort_py
Sort paths the way Python sorts Path objects: by their string form. PathBuf’s own Ord compares component-wise, which can differ when a name contains a byte below /.
walk πŸ”’