Skip to content

Add ini configuration parsing#560

Merged
qu1ck merged 5 commits into
openscopeproject:masterfrom
amauragis:apm
Jul 12, 2026
Merged

Add ini configuration parsing#560
qu1ck merged 5 commits into
openscopeproject:masterfrom
amauragis:apm

Conversation

@amauragis

@amauragis amauragis commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This pull request adds support for loading configuration options from an ini file via a new --use-ini command-line argument.

New ini-based configuration loading:

  • Added a use_ini attribute to the Config class and a corresponding --use-ini command-line argument to enable reading options from an ini file. [1] [2]
  • Implemented the set_from_args_with_ini method in Config to load configuration values from either a local or global ini file, with fallback to command-line arguments when options are missing.
  • Updated the main entry point (generate_interactive_bom.py) to call set_from_args_with_ini when --use-ini is specified.

Supersedes #432

Maybe handles #368

amauragis and others added 2 commits July 8, 2026 11:48
- highlight_pin1 is a string choice, not a bool; migrate legacy 0/1 values
  same as load_from_ini
- blacklist_empty_val is a bool in the ini file
- board_rotation is stored as int in 5-degree units; convert the CLI
  fallback value the same way set_from_args does
- read offset_back_rotation and mark_when_checked, which are written to
  the ini file but were not read back
- exit with ERROR_FILE_NOT_FOUND instead of 0 when no ini file exists

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amauragis amauragis changed the title Enhance ini file parsing and fix option types WIP: Add ini configuration parsing Jul 8, 2026
amauragis added 2 commits July 9, 2026 09:35
Explicitly-provided command line options now take precedence over values
loaded from the ini file.
Replace the repeated per-option ini lookups with a single declarative table
of (section, key, attribute, kind, cli_dest) tuples processed by a common
loop. Behaviour is unchanged; special cases (highlight_pin1 migration and
show_fields/group_fields with --extra-fields) are kept explicit.
@amauragis amauragis marked this pull request as ready for review July 9, 2026 13:38
@amauragis amauragis changed the title WIP: Add ini configuration parsing Add ini configuration parsing Jul 9, 2026
# from their argparse default). Used so that CLI options take precedence
# over values loaded from the ini file.
cli_provided = frozenset(
k for k in vars(args) if getattr(args, k) != parser.get_default(k))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you override non-default value in ini with default in cli arg?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this definitely is a problem. I ended up changing to a "ini file becomes argparse defaults" style configuration which eliminates this problem. (see 125ac03)

The parse now works like this

  1. parse_known_args() checks the pcb file and --use-ini
  2. If requested, config.get_ini_defaults() installs the ini file as parser defaults
  3. Parse args runs with the defaults (ini or otherwise) and reduces config.set_from_args().

@qu1ck qu1ck merged commit b844e73 into openscopeproject:master Jul 12, 2026
@qu1ck

qu1ck commented Jul 12, 2026

Copy link
Copy Markdown
Member

Thanks for your contribution.

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.

2 participants