Skip to content
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

Cannot call (easily) the main scancode function from Python #1780

Open
pombredanne opened this issue Oct 22, 2019 · 3 comments
Open

Cannot call (easily) the main scancode function from Python #1780

pombredanne opened this issue Oct 22, 2019 · 3 comments

Comments

@pombredanne
Copy link
Member

Description

This has been discovered during a hacking session with @valeriocos . See also chaoss/grimoirelab-graal#64

Note that we also faced #1778 reported by @AyanSinhaMahapatra

System configuration

For bug reports, it really helps us to know:

  • What OS are you running on? Linux
  • What version of scancode-toolkit was used to generate the scan file? develop
  • What installation method was used to install/run scancode? pip
@Iamshankhadeep
Copy link
Contributor

@pombredanne Can I work on it?

@pombredanne
Copy link
Member Author

@Iamshankhadeep this is a rather complex one: this about being able to call https://github.com/nexB/scancode-toolkit/blob/25d71f078f82d23a0b6ee0d0019e810430af4295/src/scancode/cli.py#L540 from another program for instance with run_scan(<absolute location of a file>, license=True, copyright=True, return_results=True) and get the results.

I know how to fix the problem ... but this requires introspection into how options are contributed by the all scancode plugins which is far from trivial. ... the **kwargs that are passed to scancode() by Click are not passed to run_scan() when you call it directly. This would likely mean digging in the innards of https://github.com/nexB/scancode-toolkit/blob/25d71f078f82d23a0b6ee0d0019e810430af4295/src/scancode/cli.py#L155 and/or may be more likely play with the values in https://github.com/nexB/scancode-toolkit/blob/25d71f078f82d23a0b6ee0d0019e810430af4295/src/scancode/cli.py#L222 to convert them to kwargs or may be use something like that https://github.com/nexB/scancode-toolkit/blob/25d71f078f82d23a0b6ee0d0019e810430af4295/src/scancode/cli.py#L233

You are welcome to have a stab at this... The first step would be to craft and commit a failing tests.

BUT I would suggest that you may look into something a tad easier like any of these two https://github.com/nexB/scancode-toolkit/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+milestone%3A%22v3.1+%22

pombredanne added a commit that referenced this issue Oct 22, 2019
This is the first setp and can be used this way:
>>> from scancode import cli
>>> rc, results = run_scan(<absolute loc a file or dir to scan>,
    license=Trye, copyright=True)

The options are overall the same as when calling the CLI

Signed-off-by: Philippe Ombredanne <[email protected]>
pombredanne added a commit that referenced this issue Oct 23, 2019
Also apply minor import and code ordering cleanups

Signed-off-by: Philippe Ombredanne <[email protected]>
pombredanne added a commit that referenced this issue Oct 23, 2019
Also apply minor import and code ordering cleanups

Signed-off-by: Philippe Ombredanne <[email protected]>
pombredanne added a commit that referenced this issue Oct 24, 2019
@pombredanne
Copy link
Member Author

This has been fixed and merged in develop. I am keeping this open to add the docs for this.

@pombredanne pombredanne modified the milestones: v3.1 , v3.2 Oct 30, 2019
viragumathe5 pushed a commit to viragumathe5/scancode-toolkit that referenced this issue Mar 13, 2020
This is the first setp and can be used this way:
>>> from scancode import cli
>>> rc, results = run_scan(<absolute loc a file or dir to scan>,
    license=Trye, copyright=True)

The options are overall the same as when calling the CLI

Signed-off-by: Philippe Ombredanne <[email protected]>
viragumathe5 pushed a commit to viragumathe5/scancode-toolkit that referenced this issue Mar 13, 2020
Also apply minor import and code ordering cleanups

Signed-off-by: Philippe Ombredanne <[email protected]>
pombredanne pushed a commit that referenced this issue Jul 14, 2021
* uniformize aliases order

* LighttpdConfLexer: add lighttpd.conf filename
@pombredanne pombredanne removed this from the v3.3 milestone Sep 24, 2021
pombredanne pushed a commit that referenced this issue Sep 8, 2022
* uniformize aliases order

* LighttpdConfLexer: add lighttpd.conf filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants