Python utility library
  • Python 98.5%
  • Makefile 1.3%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jan Lindemann 5d94a1fcee
load_yaml: Add jw.include-map
This commit adds support for interpreting a new syntax:

  jw.include-map:
    - /etc/some/file.conf: ../../../file.conf
    - /opt/blah/another/config.yaml: ../../../config.yaml

Production configs include absolute paths outside the repository tree, so a
test that runs a production-style document against repository-local copies
must redirect those includes, ideally without modifying the
files meant to be installed as is.

Add a jw.include-map key to the top-level document: an ordered list
of single-key mappings from LHS pattern to RHS pattern or list of RHS
patterns. Before resolution, the file part of each include spec is
qualified against the including file's directory and matched against the
LHS patterns in table order; the first match rewrites the spec to every RHS
pattern of that entry. Relative LHS and RHS values are interpreted against
the directory of the document that declares the map, so matching runs on
canonical paths and same-named includes from different directories stay
distinguishable. The optional marker and the target path are decomposed
before the rewrite: every rewritten source inherits the spec's optionality,
and the target path applies to the merged result.

- _parse_include_map(): parse and validate the table; only '*' is supported
  in an LHS, a RHS may not have more '*' than its LHS, and RHS values
  expand $(VAR) and ${VAR} from the environment
- _canonicalize_path(): join a relative path with a base directory and
  normalize, without disk access
- _compile_lhs_pattern(): compile a canonical LHS into an anchored regex
  whose '*' groups match runs that are not '/'
- _apply_include_map(): match the first entry and fill the LHS captures
  into every RHS pattern; log the rewrite at DEBUG
- _load_yaml(): parse the map once in the top-level document, reject it in
  included documents, thread it through the include tree

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.6.0
2026-11-20 22:39:55 +01:00
.github/workflows ci.yaml: enable-email-notifications: true 2026-06-08 14:55:11 +02:00
bin Rename the MODDIR makefile variable to JWBDIR 2019-06-29 23:32:20 +02:00
conf Rename the MODDIR makefile variable to JWBDIR 2019-06-29 23:32:20 +02:00
make project.conf: Fix pkg.requires.os.run += python3-yaml 2026-10-19 17:59:55 +02:00
scripts Add missing async keywords to jwutils.Cmd.run() reimplementations 2020-02-10 19:49:46 +01:00
src load_yaml: Add jw.include-map 2026-11-20 22:39:55 +01:00
test load_yaml: Add jw.include-map 2026-11-20 22:39:55 +01:00
.gitignore .gitignore: Follow jw-pkg 2026-09-18 10:24:53 +02:00
HASH Release 1.0.0-63 2026-11-19 01:16:50 +01:00
Makefile Makefile: Include py-topdir.mk 2026-06-12 04:55:47 +02:00
VERSION Release 1.0.0-63 2026-11-19 01:16:50 +01:00