Module dirct.key_mappers
Sub-modules
dirct.key_mappers.basename_key_mapperdirct.key_mappers.exact_key_mapperdirct.key_mappers.key_mapper
Classes
class BasenameKeyMapper (hidden: bool = True, strict: bool = True)-
A key mapper that ignores leading dots and trailing file extensions in both keys and file names.
Args
hidden- Whether to include hidden files (i.e. files starting with a dot).
strict- Whether to raise a AmbiguityError if multiple files match a key.
Methods
def get_path(self, key: str, parent: pathlib.Path) ‑> pathlib.Path | Nonedef key_of(self, path: pathlib.Path) ‑> str | None
class ExactKeyMapper-
A key mapper that maps keys and file names if and only if they are exactly the same.
Methods
def get_path(self, key: str, parent: pathlib.Path) ‑> pathlib.Path | Nonedef key_of(self, path: pathlib.Path) ‑> str | None
class KeyMapper (*args, **kwargs)-
A protocol for classes that map keys to and from paths.
Ancestors
- typing.Protocol
- typing.Generic
Methods
def get_path(self, key: str, parent: pathlib.Path) ‑> pathlib.Path | None-
Get the child of parent for the given key, or return None if the key does not correspond to a path.
def key_of(self, path: pathlib.Path) ‑> str | None-
Get the key for the given path, or return None if the path does not correspond to a key.