Make ioc -m/--macros independent of -d/--database order#53
Open
jacquelinegarrahan wants to merge 1 commit into
Open
Make ioc -m/--macros independent of -d/--database order#53jacquelinegarrahan wants to merge 1 commit into
jacquelinegarrahan wants to merge 1 commit into
Conversation
The custom DbAction snapshotted ns.macros at the moment each -d was parsed, so "-d db -m macro=value" (exactly the order in this module's own documented usage line) loaded the database with empty macros; only "-m macro=value -d db" worked. Collect database paths with a plain append action and pair them with the parsed macros after parsing, so the macros apply to every database regardless of argument order. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make
ioc-m/--macrosindependent of-d/--databaseorderBranch:
fix/ioc-macros-arg-order→masterSummary
src/python/epicscorelibs/ioc.pymain()used a custom argparse action thatsnapshotted
ns.macrosat the moment each-dwas parsed:argparse processes arguments left-to-right, so the macros only took effect for
-doptions that appeared after-m. That means:The broken order is exactly the usage documented in this module:
# Run with python -m epicscorelibs.ioc -d /path/to/db -m macro=value,macro2=value2so the documented command silently loads the database with no macro
substitution.
Fix
Collect database paths with a plain
action='append'and pair each with theparsed
args.macrosafter parsing, so a single-mapplies to every-dregardless of order:
Verification
ioc.pybyte-compiles.Note / trade-off
The previous per-
-dsnapshotting could in principle assign different macrosto different databases via interleaved
-m ... -d ... -m ... -d .... Thatbehavior was undocumented and worked only in one direction; this change makes a
single
-mapply uniformly to all databases, matching the documented CLI. Ifper-database macro sets are ever required, that should be a separate, explicit
feature (e.g.
-d db=macros).