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
readdirorder β whatos.listdir,os.scandirandglob.globreturn. 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 theglobmodule does match dotfiles.- pathlib_
rglob_ contains sorted(Path(dir).rglob(f"*{infix}*{suffix}"))β every depth, dotfiles and hidden directories included, filename must containinfixand end withsuffix.- relpath
os.path.relpath(path, start)for two absolute paths:.when equal,..segments whenpathis not understart.- sort_py
- Sort paths the way Python sorts
Pathobjects: by their string form.PathBufβs ownOrdcompares component-wise, which can differ when a name contains a byte below/. - walk π