scanoss / scanoss.py

The SCANOSS python package providing a simple, easy to consume library for interacting with SCANOSS APIs/Engine.
MIT License
27 stars 19 forks source link

add support for scanning a specified list of files #29

Closed agschrei closed 9 months ago

agschrei commented 9 months ago

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:

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.

eeisegn commented 9 months ago

@agschrei Thank you very much for the submission!

How do you plan to use this function? From the CLI or as part of an SDK integration? Trying to figure out if you're looking for this feature to exposed as part of the CLI class, or simply consumed as an SDK in another script?

agschrei commented 9 months ago

Thanks for the quick reply here @eeisegn - For my specific use case it's sufficient to have the feature exposed via the SDK.

I have a python script that consumes the scanoss.py package to implement checks as part of a pre-commit hook.
It queries git for the staged files and the idea is to then only scan these files (in parallel). I couldn't find a way to do that with the existing Scanner interface that didn't feel hacky, so I figured I'd try to upstream it.