Add modules whitelist
Thanks for this PR. Just a couple of things:
- this breaks backwards compatibility, as now
-kcan't be used alone anymore. You can addnargs="?", default=""toparser.add_argumentto have- a string if the list of the modules has been passed
- an empty string (the default) if nothing has been passed
Noneif-khas been specified, but no list has been provided Now you can just replaceif keep_modules == "all":withif keep_modules == None:.
- I think it's better if we pass a list of strings (or
Nonefor "all modules") to the twocheck_and_remove_modulesfunctions, instead of a comma-separated string. Move and adapt this part before callingcheck_and_remove_modules - break the lines if they are more than 80 characters
"None if -k has been specified, but no list has been provided"
-> Nope ;-) This is the one thing I needed sooo many times... but that does not work since argparse cannot know if the last argument after -k is -k's or file's value.
I found a way to solve this but that is very ugly.
-k, nargs="?", default="" works for these invocations:
./me_cleaner.py -k touch_fw image.bin
./me_cleaner.py -k -- image.bin
./me_cleaner.py image.bin -k
but not for ./me_cleaner.py -k image.bin for the reason stated above.
I think this is very, very ugly so my idea would be keeping -k as backward compatibly parameter and add two new parameters -W,--module-whitelist and -B, --module-blacklist or maybe -R (remove) and -K (keep). This way one can specify -k to keep all modules or one of -W, -B (-R, -K).
@corna What do you like better?
@corna any progress here? is there anything I can do?
Thank you, I'll also take a closer look at this!
--
Note: I am currently working on a new tool with clear data structures and parsing separated from logic, so I'm checking the PRs here to see what else I can integrate; see https://github.com/platform-system-interface/intel_fw