-
-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a plugin to provide more than one option #787
Comments
@pombredanne Currently each
plugin('*.txt')
plugin('^\.') or
plugin(dict('ignore-glob'='*.txt', 'ignore-regex'='^\.')) |
Also, should we add a common plugin prefix to the options? say if |
@yashdsaraf Thanks... here is my thinking on this:
With this, the only thing that a plugin would declare in the entry point is its "name" and its plugin callable for a given stage of the scan (pre, scan, post, output). All options would be provided by the plugin class itself. And all plugins would have the same interface: act on a stream of Resources. This would mean reworking the way all the plugins work today to a single common way. Does this make sense? |
Okay, this is what I got from that
I think it's better to start restructuring the plugins to take in iterable of resource, rest points will follow automatically. |
perfect! |
@pombredanne Like you said, ultimately all the plugins would return an iterable of resources. In this case, how would the output plugins work? |
Good point: the output plugins could eitherr:
The later is likely cleaner |
I'm sorry I didn't get that, could you give an example of what should happen if a user calls scancode cli with multiple format options. |
See the discussion in #789 |
Ah, got it. Each option supplied by the format plugins would take the output file path as input. |
@yashdsaraf no path given would mean stdout output which would be messy if there are more than one ; ) but that's OK, we cannot prevent folks to shoot themselves in the foot |
Signed-off-by: Yash D. Saraf <[email protected]>
@yashdsaraf I think what would be most useful for @haikoschol is to have this available for post-scan plugins right now. Do you think you can have a look into this? Or shall I take a stab? |
Signed-off-by: Yash D. Saraf <[email protected]>
Signed-off-by: Yash D. Saraf <[email protected]>
Shoot, in working to encapsulate Resources with PyFilesystem, I did hit PyFilesystem/pyfilesystem2#120 and #688 .... sigh. I need to beef things up to make things work :| |
FYI I submitted a PR to PyFilesystem/pyfilesystem2#121 in order to have proper handling of non-fs decoable bytes-only paths. Based on this I am going forward with the refactoring of the Resource and scan pipeline around PyFilesystem2 which should provide a clean abstraction and simplify vastly creating new plugins |
Signed-off-by: Yash D. Saraf <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* otherwise some test fail in somce layouts Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* all plugins are now required to declare which attributes they add to the scan as a list of attr attributes as declare the sort order in which these should appear on the scan results * To suppprt these plugin-contributed scan attributes, a new Resource subclass is created on the fly based on plugin provided attributes * Since Scanners functions return the actual attributes that are set directty on the Resource oject, the API has been updated accordingly. Scanner functions now return a mapping. * the whole Resource caching system has been updated: resources are either entirely in memory or entirely serialized on disk for caching. The new --max-in-memory option sets how many Resources are kept in RAM, default to 10K. * codebases are no longer cached in a ugly globals * only pre-scan plugins can defined a set of "requires" scans that are executed in a scan stage before the "pre-scan" (a tad of an ugly name). * no option is used as a default anymoe: all options need to be set explicitly (such as mark-source needing info) * codebase.remove_resource can now remove resource during a walk safely * info is now a proper scanner and is no longer super special * the plugin entrypoint name is NOT used anymore as the primary key for scan results attribute of a scan * cli.run_scanners is a new function to encapsulate the scanner runs Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* ensure that a File option used in output cannot bet set to the value of a command line option. This is done with FileOptionType, a click.File subclass that verifies that a file name is not one of the avaialble options and fails if this is the case. Reported by @JonoYang * move CommandLineOption to scancode.__init__.py * add new args to CommandLineOption: requires and conflicts. Each are a sequence of other option names that either conflict with this option or are require to be set with this option. --strip-root, --full-root, --verbose, --quiet and plugin options with option dependencies are now using this feature. The CLI fails early if requirements are not met or conflicts exist. Added a few simple tests for this. * add new sort_order arg to CommandLineOption and used it to set a relative sort order for options helps in a help group * add new documentation CLI help_group for help and other related options. Reorganized CLI help * renamed json-realted output CLI options to plain json-* Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* for now all stages are catching exceptions and rethrowing them with an error message(except for scan stages that already catch exceptions). This stops the executaion. A better way would be to continue trucking and disable the faulty plugins Signed-off-by: Philippe Ombredanne <[email protected]>
* the plugin for license reindexing is updated in next commit Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* reported by @haikoschol at #885 (comment) Signed-off-by: Philippe Ombredanne <[email protected]>
* reported by @haikoschol Signed-off-by: Philippe Ombredanne <[email protected]>
* reported by @haikoschol * timings are now correctly added if requested to each Resource * there is a test to ensure this works and is included in JSON and JSON lines outputs * minor refactor of cli_test_utils.py and other minor clieanups Signed-off-by: Philippe Ombredanne <[email protected]>
* tests were failing on Windows otehrwise Signed-off-by: Philippe Ombredanne <[email protected]>
* this can happen if info scan failed somehow Signed-off-by: Philippe Ombredanne <[email protected]>
* otherwise some test fail in somce layouts Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
Signed-off-by: Philippe Ombredanne <[email protected]>
* all plugins are now required to declare which attributes they add to the scan as a list of attr attributes as declare the sort order in which these should appear on the scan results * To suppprt these plugin-contributed scan attributes, a new Resource subclass is created on the fly based on plugin provided attributes * Since Scanners functions return the actual attributes that are set directty on the Resource oject, the API has been updated accordingly. Scanner functions now return a mapping. * the whole Resource caching system has been updated: resources are either entirely in memory or entirely serialized on disk for caching. The new --max-in-memory option sets how many Resources are kept in RAM, default to 10K. * codebases are no longer cached in a ugly globals * only pre-scan plugins can defined a set of "requires" scans that are executed in a scan stage before the "pre-scan" (a tad of an ugly name). * no option is used as a default anymoe: all options need to be set explicitly (such as mark-source needing info) * codebase.remove_resource can now remove resource during a walk safely * info is now a proper scanner and is no longer super special * the plugin entrypoint name is NOT used anymore as the primary key for scan results attribute of a scan * cli.run_scanners is a new function to encapsulate the scanner runs Signed-off-by: Philippe Ombredanne <[email protected]>
* also ensure that the extractcode cli does not depend on scancode cli. Signed-off-by: Philippe Ombredanne <[email protected]>
Merged in develop with #885 ! |
* also ensure that the extractcode cli does not depend on scancode cli. Signed-off-by: Philippe Ombredanne <[email protected]>
We should have a way for a plugin to provide not one, but several CLI options
Also a plugin should be able to provide fully configured click Options as options and not be constrained in what the options args are.
This is needed whenever more than one option is required or when more advanced settings need to be provided for a given option. This would be needed for scan plugins where several have multiple options.
@yashdsaraf ping :)
The text was updated successfully, but these errors were encountered: