jgdv.mixins.path_manip
Enums
Create a collection of name/value pairs. |
Classes
A Mixin for common path manipulations |
|
A Mixin for walking directories, |
Module Contents
- class jgdv.mixins.path_manip.LoopControl_e(*args, **kwds)[source]
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- no
- noBut
- yes
- yesAnd
- class jgdv.mixins.path_manip.PathManip_m[source]
A Mixin for common path manipulations
- _build_roots(*sources, roots=None) <Unknown>[source]
convert roots from keys to paths
- Parameters:
sources (collections.abc.Mapping)
- Return type:
- _calc_path_parts(fpath, roots) <Unknown>[source]
take a path, and get a dict of bits which aren’t methods of Path if no roots are provided use cwd
- Parameters:
fpath (pathlib.Path)
roots (list[pathlib.Path])
- Return type:
- _find_parent_marker(
- fpath,
- marker=None,
Go up the parent list to find a marker file, return the dir its in
- Parameters:
fpath (pathlib.Path)
marker (jgdv.Maybe[str])
- Return type:
jgdv.Maybe[pathlib.Path]
- _get_relative(fpath, roots=None) <Unknown>[source]
Get relative path of fpath. if no roots are provided, default to using cwd
- Parameters:
fpath (pathlib.Path)
roots (jgdv.Maybe[list[pathlib.Path]])
- Return type:
- _normalize(
- path,
- *,
- root=None,
- symlinks=False,
a basic path normalization expands user, and resolves the location to be absolute
- Parameters:
path (pathlib.Path)
root (jgdv.Maybe[pathlib.Path])
symlinks (bool)
- Return type:
- abstractmethod _shadow_path(rpath, shadow_root) <Unknown>[source]
take a relative path, apply it onto a root to create a shadowed location
- Parameters:
rpath (pathlib.Path)
shadow_root (pathlib.Path)
- Return type:
- class jgdv.mixins.path_manip.Walker_m[source]
A Mixin for walking directories, written for py<3.12
- walk_all(
- roots,
- *,
- exts=None,
- rec=False,
- fn=None,
walk all available targets, and generate unique names for them
- Parameters:
roots (list[pathlib.Path])
rec (bool)
fn (jgdv.Maybe[collections.abc.Callable])
- Return type:
- walk_target_deep(
- target,
- *,
- exts=None,
- fn=None,
- Parameters:
target (pathlib.Path)
fn (jgdv.Maybe[collections.abc.Callable])
- Return type:
- walk_target_shallow(
- target,
- *,
- exts=None,
- fn=None,
- Parameters:
target (pathlib.Path)
fn (jgdv.Maybe[collections.abc.Callable])
- Return type:
- control_e: ClassVar[type[LoopControl_e]]