fix: make module print order configurable via DEFAULT_OPTIONS#26
Open
gandzekas wants to merge 1 commit into
Open
fix: make module print order configurable via DEFAULT_OPTIONS#26gandzekas wants to merge 1 commit into
gandzekas wants to merge 1 commit into
Conversation
Addresses issue brick-24#24: the order in which modules are printed was hardcoded in daily_arg.py. Now the print order is driven by config.DEFAULT_OPTIONS. - Added OPTION_HANDLERS mapping option names to (handler, arg_getter, is_flag) - Added DEFAULT_ORDER = DEFAULT_OPTIONS + remaining handlers - Refactored main() to execute handlers in DEFAULT_ORDER - When no explicit flags provided, DEFAULT_OPTIONS are enabled in configured order - When explicit flags provided, they execute in DEFAULT_ORDER priority - Improved argparse help strings for clarity - Added _is_option_enabled() and _get_active_options() helpers
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.
Summary
Fixes issue #24: the order in which modules are printed was hardcoded in
daily_arg.py. Now the print order is driven byconfig.DEFAULT_OPTIONS.Changes
OPTION_HANDLERSmapping and dynamic execution order:OPTION_HANDLERS(OrderedDict) mapping option names to(handler_fn, arg_getter, is_flag)DEFAULT_ORDER=DEFAULT_OPTIONS+ remaining handlers in declaration order_is_option_enabled(args, opt)and_get_active_options(args)helpersmain()to iterate handlers in resolved orderDEFAULT_OPTIONSin configured orderDEFAULT_ORDERpriorityBehavior
DEFAULT_OPTIONSorder (configurable inconfig.py)--markets --weather): prints only requested modules, ordered byDEFAULT_ORDERpriority--xkcd --quote --stock AAPL): executes inDEFAULT_ORDER(quote → xkcd → stock)Testing
python -m py_compile daily_arg.py config.py printer.py function/*.py— syntax OKRelated