add support for scanning a specified list of files #29
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.
This PR adds additional methods to
Scanner
that accept a list of file paths to be scanned.Why we think this is an added convenience for users:
We are currently using scanoss.py to build a git pre-commit hook. Ideally this hook should only scan files that are in the git staging area which was difficult to achieve with the existing methods exposed by
Scanner
.There are some things that can be done by directly calling internal methods directly, but that's just asking for trouble.
Caveats:
scan_files
method is essentially a carbon copy of thescan_folder
method with the only difference that, instead of walking a filesystem directory, it simply iterates over a list of paths. The code may benefit from DRYing things up to reduce this duplication, I am happy to take a stab at it with some guidance.scan_files_with_options method
will raise an exception if invoked with dependency scan mode enabled. This is because the interface for the dependency scan also expects a single root path that it will then scan with scancode. I have not refactored this yet so flagging the scan mode as unsupported seemed like the best option for now.Any feedback on this is welcome. I am using my own custom build for our pre-commit hook right now, but would of course prefer to upstream this if possible.