Use gentoo licenses as a test data set
See https://gitweb.gentoo.org/repo/gentoo.git/tree/licenses
@pombredanne I would like to work on in this issue.
@pombredanne I want to confirm that for this issue I just have to add the gentoo/gentoo/licenses list to the existing data set of aboutcode source code.
The approach should be
-
run the license detection on the dataset
-
for each file that is is not detected 100% there are two cases possible:
2.1 this is a new license: then create a new license. each new license creation should go in its own PR. for new licenses, the key should be all ascii, lowercase. Suggest one with each new license and we can discuss in the PR which would be the best.
2.2 this is a new variant of an existing license: then add a new rule and a test
And each and every file in the dataset should be pushed as a new test in tests/licensedcode/data/licenses
So my suggestion is to start small, one gentoo file at a time, not all at once: otherwise this would be too much work to review at once for us: small bites are best
See https://github.com/nexB/scancode-toolkit/wiki/How-to:-Add-new-license-rules-for-enhanced-detection
For a license the principle is the same, but you need a .yml and .LICENSE file pair for each license.
So see it all in action consider the for instance the files for the apache-1.0 licenses
-
the reference license with its data and text file:
- data file ass YAML: https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/licenses/apache-1.0.yml
- license text: https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/licenses/apache-1.0.LICENSE
-
example of an additional detection rule for this license:
- https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/rules/apache-1.0.RULE
- https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/rules/apache-1.0.yml
-
other example of an additional rule for this license:
- https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/rules/apache-1.0_1.RULE
- https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/src/licensedcode/data/rules/apache-1.0_1.RULE
-
and example of a detection test, here detecting two licenses at once:
- file to test : https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/tests/licensedcode/data/licenses/apache-1.0.txt
- expected detection results for this file: https://github.com/nexB/scancode-toolkit/blob/06cd94c127b82549382c61d3adec47e930923db1/tests/licensedcode/data/licenses/apache-1.0.yml
See also the FAQ of course https://github.com/nexB/scancode-toolkit/wiki/FAQ
And to put it all in context the internal design of the license detection is document here: https://github.com/nexB/scancode-toolkit/blob/develop/src/licensedcode/README.rst
As you stated i ran the scan(for Zurich Instruments license) with additional arguments and got this as output.
1.https://gist.github.com/aj4ayushjain/d5731fac7fec5581a80ad1130db926fd Which is as expected.So, we should put all license one rule under "Propriertary" key where all the proprietary license will be covered?
2.Regarding the script(data driven framework) for license scan the standarization of this script(for all ) seems tough any suggestion ie each license is stored differently on each website
@aj4ayushjain
-
you should create a new proprietary license rule for the this Zurich license full text. See the many examples in scancode-toolkit/src/data/rules and submit a PR
-
I am not sure what you mean but here is a way to craft ~700+ new tests for a start:
- fetch and copy all the licenses
git clone --depth=10 git://git.gentoo.org/repo/gentoo.git
mv gentoo/licenses/ ~/scancode-toolkit/tests/licensedcode/data/gentoo_licenses/
- add a txt extension to each license text and create bare .yml expectation file for each license:
cd ~/scancode-toolkit/tests/licensedcode/data/gentoo_licenses/
for f in *
do
echo "notes: a license from Gentoo" > $f.yml
mv $f $f.txt
done
- Edit ``/scancode-toolkit/tests/licensedcode/test_detection_datadriven.py` and add this at the bottom.
class TestsGentooLicensesDataDriven(unittest.TestCase):
# licenses from gentoo
pass
build_tests(
join(TEST_DIR, 'gentoo_licenses'),
clazz=TestsGentooLicensesDataDriven, regen=True)
-
run these new tests once:
py.test -vvs -n4 tests/licensedcode -k TestsGentooLicensesDataDriven -
remove the regen flag:
clazz=TestsGentooLicensesDataDriven, regen=False) -
review now all the generated yaml expectation files. Eventually rerun detection by hand with the --license-diag and --license-text on each of them if the license is not correctly detected than create new rules and/or update the yml file and/or create new licenses in some cases.
@aj4ayushjain ping? is this something that you are working on or not?
@pombredanne Ping ! I got caught up in writing the gsoc proposal and after 2-3 days i will continue working on this .
As you instructed i created the test file and .yml but running
py.test -vvs -n4 tests/licensedcode -k TestsGentooLicensesDataDriven
gives error as
Couldn't figure it out.
Each test file needs to have a counterpart YAML data file that contains the test expectations.
The convention was to have a test file name.foo with a data file name.yml
This has changed since and now we use name.foo with a data file name.foo.yml
So the code to create basic empty YAML is out of date and should be:
for f in *
do
echo "notes: a license from Gentoo" > $f.txt.yml
mv $f $f.txt
done
hi i would like to contribute to this issue. is it available?
Great! You can go ahead it's available.