App: Move project.conf parsing into lib.ProjectConf #43

Merged
Jan Lindemann merged 5 commits from jan/feature/20260630-app-get-section-remove-method into master 2026-06-30 14:04:35 +02:00 AGit

2026-06-30

App.get_section(): Remove method
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m24s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m5s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m59s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m12s
CI / Packaging test (push) Successful in 0s
Remove App.get_section() which parses raw file sections by scanning for
section headers and accumulating lines. This method is no longer needed
since ProjectConf now handles all config file parsing.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-30 12:46:51 +02:00
App: Use ProjectConf
Refactor App to use the new ProjectConf module for parsing
make/project.conf files.

This commit

  - removes the inline ad-hoc read_value() method and its nested
    helper functions, replacing them with ProjectConf's
    get_str_or_none() API.

  - introduces two cached helper methods (__read_project_conf() and
    __get_project_conf()) to read and cache ProjectConf instances per
    project.

  - updates get_value() to delegate to ProjectConf and moves the
    proj_dir lookup to only run in the version branch where it is
    needed.

  - updates the topdir init to use __read_project_conf() with a
    FileNotFoundError catch for optional config files.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-30 12:46:48 +02:00
Jan Lindemann
test: ProjectConf: Add unit tests
Add unit tests for the new ProjectConf module covering:

  - Basic string and list value retrieval (get_str(), get_str_or_none(),
    get_list(), get_list_or_none())
  - Quoted values with preserved spaces and comment delimiters
  - Inline comments outside quotes
  - Comma-separated lists with quoted commas
  - Line continuations
  - Multiple sections
  - Error cases: empty key, missing key/section, malformed sections,
    unfinished continuations, unclosed quotes
  - Error class is a subclass of ValueError

Also include a Makefile for running tests via `make test`.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-30 12:46:42 +02:00
lib.ProjectConf: Add module
Introduce ProjectConf module to cleanly parse make/project.conf ini-like
configuration files. The new class supports:

  - ini-style sections with header comments
  - Key-value pairs with backslash line continuation
  - Quoted values preserving spaces and comment delimiters (#) inside
  - Inline comments outside of quotes
  - Comma-separated list values with quoted commas
  - Cached section parsing to avoid re-parsing the same section
  - .get_section() to return an entire section unparsed

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-30 12:46:36 +02:00
App: Replace @lru_cache() with @cache
Replace the @functools.lru_cache(maxsize=None) decorator with
@functools.cache throughout App. functools.cache is a shorthand for
functools.lru_cache(maxsize=None) introduced in Python 3.9 and is
more concise and readable with identical behaviour.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-30 12:46:28 +02:00