jgdv.mixins.path_manip

Enums

LoopControl_e

Create a collection of name/value pairs.

Classes

PathManip_m

A Mixin for common path manipulations

Walker_m

A Mixin for walking directories,

Module Contents

class jgdv.mixins.path_manip.LoopControl_e(*args, **kwds)[source]

Bases: enum.Enum

Create 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:
Return type:

list[pathlib.Path]

_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:
Return type:

dict

_find_parent_marker(
fpath,
marker=None,
) <Unknown>[source]

Go up the parent list to find a marker file, return the dir its in

Parameters:
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:
Return type:

pathlib.Path

_normalize(
path,
*,
root=None,
symlinks=False,
) <Unknown>[source]

a basic path normalization expands user, and resolves the location to be absolute

Parameters:
Return type:

pathlib.Path

abstractmethod _shadow_path(rpath, shadow_root) <Unknown>[source]

take a relative path, apply it onto a root to create a shadowed location

Parameters:
Return type:

pathlib.Path

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,
) <Unknown>[source]

walk all available targets, and generate unique names for them

Parameters:
Return type:

list[dict]

walk_target_deep(
target,
*,
exts=None,
fn=None,
) <Unknown>[source]
Parameters:
Return type:

collections.abc.Generator[pathlib.Path]

walk_target_shallow(
target,
*,
exts=None,
fn=None,
) <Unknown>[source]
Parameters:
Return type:

collections.abc.Generator

control_e: ClassVar[type[LoopControl_e]]