Skip to content

Dictionary lookup of event loop actions

Administrator requested to merge cclauss:patch-1 into master

This was kind of an experiment that adds lots of blank lines to this script -- feel free to reject it. (102 additions / 47 deletions :-( )

The observation that triggered this was that in main() all actions can execute using just one parameter, args. This means that it is possible to use args.action to do a dict lookup to get the corresponding function. This approach adds tons of blank lines to the script in exchange for a rapid seek to the action implementation and a substantial reduction of the McCabe complexity of main().

$ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

./pmbootstrap.py:43:1: C901 'main' is too complex (23)
./pmb/aportgen/core.py:38:1: C901 'rewrite' is too complex (17)
[ ... ]

Merge request reports

Loading