topmark.config.paths¶
Pure helpers for path normalization and PatternSource construction.
These utilities centralize the path resolution rules used by config loading and
CLI overrides. They do no I/O beyond Path.resolve() and have no imports
from the rest of TopMark (except logging/types), which makes them safe to use
across modules.
Key behaviors
abs_path_from(base, raw): resolverawagainstbasewhen relative; always returns an absolute, resolvedpathlib.Path.ps_from_config(raw, config_dir): create aPatternSourcefor a path declared inside a config file, anchoring to that file's directory.ps_from_cli(raw, cwd): same, but for CLI-declared paths, anchoring to the invocation CWD.extend_pattern_sources(dst, items, mk, kind, base): batch-normalize a sequence of raw entries intodstusing the provided factory.
Policy recap
- Globs are evaluated later, relative to
relative_to. - Files that contain patterns (
*_from) are normalized immediately, and each carries abase(usuallypath.parent) for consistent matching.
abs_path_from ¶
Return an absolute Path for raw using base if raw is relative.
Source code in src/topmark/config/paths.py
pattern_source_from_config ¶
Create PatternSource from a config-file-declared path using that file's directory.
Source code in src/topmark/config/paths.py
pattern_source_from_cwd ¶
Create PatternSource from a CLI-declared path using CWD (invocation site).
extend_pattern_sources ¶
Append pattern sources created from items to dst.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
Iterable[str]
|
Raw pattern declarations to normalize; skipped if falsy. |
required |
dst
|
list[PatternSource]
|
Destination list to extend in-place. |
required |
mk
|
Callable[[str, Path], PatternSource]
|
Factory that materializes a |
required |
kind
|
str
|
Human-readable label used for debug logging. |
required |
base
|
Path
|
Directory against which relative entries are resolved. |
required |