boilercore.paths#

Paths and modules.

Module Contents#

Classes#

Submodule

Represents a git submodule.

Functions#

get_package_dir

Get the directory of a package given the top-level module.

get_module_name

Get an unqualified module name.

get_qualified_module_name

Get a fully-qualified module name.

dt_fromisolike

Get datetime like ISO 8601 but with flexible delimeters and missing century.

map_stages

Map stage module names to their paths.

get_module_rel

Get module name relative to another module.

walk_modules

Walk modules from a given submodule path and the top level library directory.

walk_module_map

Walk the map of modules to their paths.

get_qualified_module_name_from_paths

Get the qualified name of a module file relative to a package file.

walk_module_paths

Walk the paths of a Python package.

get_suffixes_re

Get the regex pattern string for file suffixes.

get_suffix_re

Get the regex pattern string for a file suffix.

walk_matches

Walk a directory returning regex or glob matches.

fold

Resolve and normalize a path to a POSIX string path with forward slashes.

modified

Check whether notebook is modified.

get_changes

Get pending changes.

get_submodules

Get the special template and typings submodules, as well as the rest.

Data#

API#

boilercore.paths.get_package_dir(
package: types.ModuleType,
) pathlib.Path#

Get the directory of a package given the top-level module.

boilercore.paths.get_module_name(
module: types.ModuleType | importlib.machinery.ModuleSpec | pathlib.Path | str,
) str#

Get an unqualified module name.

Example: get_module_name(__spec__ or __file__).

boilercore.paths.get_qualified_module_name(
module: types.ModuleType | importlib.machinery.ModuleSpec,
) str#

Get a fully-qualified module name.

Example: get_module_name(__spec__ or __file__).

boilercore.paths.dt_fromisolike(
match: re.Match[str],
century: int | str = 20,
) datetime.datetime#

Get datetime like ISO 8601 but with flexible delimeters and missing century.

boilercore.paths.GROUP#

‘Template(…)’

boilercore.paths.SUBSTITUTIONS#

None

boilercore.paths.ISOLIKE_PATTERN#

‘substitute(…)’

boilercore.paths.ISOLIKE#

‘compile(…)’

boilercore.paths.DEFAULT_SUFFIXES#

[‘.py’]

boilercore.paths.map_stages(
package: pathlib.Path,
suffixes=DEFAULT_SUFFIXES,
) dict[str, pathlib.Path]#

Map stage module names to their paths.

boilercore.paths.get_module_rel(
module: str,
relative: str,
) str#

Get module name relative to another module.

boilercore.paths.walk_modules(
package: pathlib.Path,
suffixes: list[str] = DEFAULT_SUFFIXES,
) collections.abc.Iterable[str]#

Walk modules from a given submodule path and the top level library directory.

boilercore.paths.walk_module_map(
package: pathlib.Path,
suffixes: list[str] = DEFAULT_SUFFIXES,
) collections.abc.Iterable[tuple[str, pathlib.Path]]#

Walk the map of modules to their paths.

boilercore.paths.get_qualified_module_name_from_paths(
module: pathlib.Path,
package: pathlib.Path,
) str#

Get the qualified name of a module file relative to a package file.

boilercore.paths.walk_module_paths(
package: pathlib.Path,
suffixes: list[str] = DEFAULT_SUFFIXES,
) collections.abc.Iterable[pathlib.Path]#

Walk the paths of a Python package.

boilercore.paths.get_suffixes_re(
suffixes: list[str],
) str#

Get the regex pattern string for file suffixes.

boilercore.paths.get_suffix_re(
suffix: str,
) str#

Get the regex pattern string for a file suffix.

boilercore.paths.walk_matches(
path: pathlib.Path,
glob: str | None = None,
regex: str | None = None,
root_regex: str | None = None,
flags=NOFLAG,
) collections.abc.Iterable[pathlib.Path]#

Walk a directory returning regex or glob matches.

boilercore.paths.fold(
path: pathlib.Path,
resolve: bool = True,
) str#

Resolve and normalize a path to a POSIX string path with forward slashes.

boilercore.paths.modified(
nb: pathlib.Path | str,
) bool#

Check whether notebook is modified.

boilercore.paths.get_changes() list[pathlib.Path]#

Get pending changes.

class boilercore.paths.Submodule#

Represents a git submodule.

_path: str | bytes#

None

Submodule path as reported by the submodule source.

commit: str#

None

Commit hash currently tracked by the submodule.

path: pathlib.Path#

‘Path(…)’

Submodule path.

name: str = <Multiline-String>#

Submodule name.

__post_init__()#

Handle byte strings reported by some submodule sources, like dulwich.

boilercore.paths.get_submodules() list[boilercore.paths.Submodule]#

Get the special template and typings submodules, as well as the rest.