Skip to content

WordLoom implementation extensions: file_bindings#1

Open
uogbuji wants to merge 4 commits intomainfrom
feature/file-inclusion
Open

WordLoom implementation extensions: file_bindings#1
uogbuji wants to merge 4 commits intomainfrom
feature/file-inclusion

Conversation

@uogbuji
Copy link
Copy Markdown
Contributor

@uogbuji uogbuji commented Apr 30, 2026

pylib/ext/file_includes.py: extension module. Has resolve_file_bindings() and internal helpers for file:, dir:, and glob: reference resolution, with directory-traversal protection, size/encoding guards, and hidden-path filtering. Adapted and cleaned up from the scratch prototype.

pylib/wordloom.py:

  • language_item gains a file_bindings: dict attribute (empty by default) and a render(**kwargs) method that merges file_bindings with runtime kwargs before formatting. clone() also preserves file_bindings.
  • load() gains features= (set or dict; {'file-inclusion'} enables the extension) and base_dir= (explicit override). It auto-detects the loom base directory from Path arguments, path strings, and open() handles. The extension import is deferred inside load() so the extension is only loaded when the feature is active.

test/test_file_inclusion.py: 16 tests covering file:, dir: & glob: resolution, all three input forms (Path, open handle, path string), render() merging, security rejections (path traversal, absolute paths, missing files, .. in globs), base_dir= override & clone() propagation.

implementation.md: developer-facing doc covering package layout, language_item attributes and methods, the full load() parameter reference, and a detailed section on the file-inclusion extension including TOML syntax, the three schemes, security model, and the base-directory requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant