polymerist.genutils.fileutils.pathutils ======================================= .. py:module:: polymerist.genutils.fileutils.pathutils .. autoapi-nested-parse:: Utilities for editing, augmenting, and querying Paths Attributes ---------- .. autoapisummary:: polymerist.genutils.fileutils.pathutils.T polymerist.genutils.fileutils.pathutils.Params Functions --------- .. autoapisummary:: polymerist.genutils.fileutils.pathutils.aspath polymerist.genutils.fileutils.pathutils.asstrpath polymerist.genutils.fileutils.pathutils.allow_string_paths polymerist.genutils.fileutils.pathutils.allow_pathlib_paths polymerist.genutils.fileutils.pathutils.is_empty_dir polymerist.genutils.fileutils.pathutils.is_empty_file polymerist.genutils.fileutils.pathutils.is_empty polymerist.genutils.fileutils.pathutils.assemble_path polymerist.genutils.fileutils.pathutils.dotless polymerist.genutils.fileutils.pathutils.default_suffix polymerist.genutils.fileutils.pathutils.prepend_parent polymerist.genutils.fileutils.pathutils.detach_parent polymerist.genutils.fileutils.pathutils.exchange_parent polymerist.genutils.fileutils.pathutils.local_rename polymerist.genutils.fileutils.pathutils.local_restem Module Contents --------------- .. py:data:: T .. py:data:: Params .. py:function:: aspath(path: Union[str, pathlib.Path]) -> pathlib.Path Allow functions which expect Paths to also accept strings .. py:function:: asstrpath(strpath: Union[str, pathlib.Path]) -> str Allow functions which expect strings paths to also accept Paths .. py:function:: allow_string_paths(funct: Callable[[Concatenate[pathlib.Path, Params]], T]) -> Callable[[Concatenate[Union[pathlib.Path, str], Params]], T] Modifies a function which expects a Path as its first argument to also accept string-paths .. py:function:: allow_pathlib_paths(funct: Callable[[Concatenate[str, Params]], T]) -> Callable[[Concatenate[Union[pathlib.Path, str], Params]], T] Modifies a function which expects a string path as its first argument to also accept canonical pathlib Paths .. py:function:: is_empty_dir(dirpath: pathlib.Path) -> bool Check if a directory contains no files .. py:function:: is_empty_file(filepath: pathlib.Path) -> bool Check if a file contains no data .. py:function:: is_empty(path: pathlib.Path) -> bool Flexibly check whether a path is "empty" If path point to a file, returns whether the file contains data If path points to a directory, returns whether the directory contains any files (empty or otherwise) .. py:function:: assemble_path(directory: pathlib.Path, prefix: str, extension: str, postfix: str = '') -> pathlib.Path Combine output, naming, descriptive, and filetype info to generate a complete Path .. py:function:: dotless(path: pathlib.Path) -> str Separate the dot from file path. Returns the original suffix if not dot is present .. py:function:: default_suffix(path: pathlib.Path, suffix: str) -> pathlib.Path Asserts that a path has a suffix, appending a specified default suffix if none exists .. py:function:: prepend_parent(path: pathlib.Path, new_parent: pathlib.Path) -> pathlib.Path Prepends a parent tree to an existing path .. py:function:: detach_parent(path: pathlib.Path, old_parent: pathlib.Path) -> pathlib.Path Cuts off a parent tree from an existing path .. py:function:: exchange_parent(path: pathlib.Path, old_parent: pathlib.Path, new_parent: pathlib.Path) -> pathlib.Path Exchanges the parent tree of a path for another parent tree .. py:function:: local_rename(path: pathlib.Path, new_name: str) -> pathlib.Path Performs file rename relative to the parent directory (NOT the cwd) .. py:function:: local_restem(path: pathlib.Path, new_stem: str) -> pathlib.Path Performs file rename relative to the parent directory (NOT the cwd), preserving the extension of the original file