-
-
Notifications
You must be signed in to change notification settings - Fork 27
retire license category reporting #116
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
Closed
iamsid2
wants to merge
2
commits into
aboutcode-org:develop
from
iamsid2:retire_license_category_reporting
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
etc/scripts/testdata/json2csv/copyright_and_license_info_added.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| Score,Factors,Path,Name,Type,Size,Old Path | ||
| 70,modified license info added copyleft added copyright info added,path.txt,path.txt,file,300, | ||
| 70,modified license info added copyright info added,path.txt,path.txt,file,300, |
4 changes: 2 additions & 2 deletions
4
etc/scripts/testdata/json2csv/copyright_and_license_info_added.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| Score,Factors,Path,Name,Type,Size,Old Path | ||
| 70,modified license info added copyleft added copyright info removed,path.txt,path.txt,file,300, | ||
| 70,modified license info added copyright info removed,path.txt,path.txt,file,300, |
4 changes: 2 additions & 2 deletions
4
etc/scripts/testdata/json2csv/license_info_added_copyright_info_removed.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Score,Factors,Path,Name,Type,Size,Old Path | ||
| 50,modified license change,some/path/a/a1.py,a1.py,file,300, | ||
| 20,modified,some/path/c/c1.py,c1.py,file,300, | ||
| 30,modified license change,some/path/b/b1.py,b1.py,file,300, | ||
| 50,modified license change copyleft added,some/path/a/a1.py,a1.py,file,300, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,9 +35,9 @@ | |
|
|
||
| def update_from_license_info(delta, unique_categories): | ||
| """ | ||
| Increase an 'added' or 'modified' Delta object's 'score' attribute and add | ||
| one or more appropriate categories to its 'factors' attribute if there has | ||
| been a license change and depending on the nature of that change. | ||
| Increase an 'added' or 'modified' Delta object's 'score' attribute and | ||
| annotate its 'factors' attribute if there has been a license change and | ||
| depending on the nature of that change. | ||
| """ | ||
| if delta.is_added(): | ||
| update_added_from_license_info(delta, unique_categories) | ||
|
|
@@ -48,70 +48,71 @@ def update_from_license_info(delta, unique_categories): | |
|
|
||
| def update_added_from_license_info(delta, unique_categories): | ||
| """ | ||
| Increase an 'added' Delta object's 'score' attribute and add | ||
| one or more categories to its 'factors' attribute if there has | ||
| been a license change. | ||
| Increase an 'added' Delta object's 'score' attribute and annotate its | ||
| 'factors' attribute if there has been a license change. | ||
| """ | ||
| new_licenses = delta.new_file.licenses or [] | ||
| new_categories = set(license.category for license in new_licenses) | ||
|
|
||
| if delta.new_file.has_licenses(): | ||
| delta.update(20, 'license info added') | ||
|
|
||
| for category in new_categories: | ||
| # no license ==> 'Copyleft Limited'or higher | ||
| if category in unique_categories: | ||
| delta.update(20, category.lower() + ' added') | ||
| # no license ==> 'Permissive' or 'Public Domain' | ||
| else: | ||
| delta.update(0, category.lower() + ' added') | ||
| # delta.update(20, 'license info added') | ||
| # | ||
| # for category in new_categories: | ||
| # # no license ==> 'Copyleft Limited'or higher | ||
| # if category in unique_categories: | ||
| # delta.update(20, category.lower() + ' added') | ||
| # # no license ==> 'Permissive' or 'Public Domain' | ||
| # else: | ||
| # delta.update(0, category.lower() + ' added') | ||
| delta.update(score=20, factor='license info added') | ||
| return | ||
|
|
||
|
|
||
| def update_modified_from_license_info(delta, unique_categories): | ||
| """ | ||
| Increase a 'modified' Delta object's 'score' attribute and add | ||
| one or more categories to its 'factors' attribute if there has | ||
| been a license change. | ||
| Increase a 'modified' Delta object's 'score' attribute and annotate its | ||
| 'factors' attribute if there has been a license change. | ||
| """ | ||
| if not delta.new_file.has_licenses() and delta.old_file.has_licenses(): | ||
| delta.update(15, 'license info removed') | ||
| delta.update(score=15, factor='license info removed') | ||
| return | ||
|
|
||
| new_licenses = delta.new_file.licenses or [] | ||
| old_licenses = delta.old_file.licenses or [] | ||
|
|
||
| new_categories = set(license.category for license in new_licenses) | ||
| old_categories = set(license.category for license in old_licenses) | ||
| # new_categories = set(license.category for license in new_licenses) | ||
| # old_categories = set(license.category for license in old_licenses) | ||
|
|
||
| if delta.new_file.has_licenses() and not delta.old_file.has_licenses(): | ||
| delta.update(20, 'license info added') | ||
|
|
||
| for category in new_categories: | ||
| # no license ==> 'Copyleft Limited'or higher | ||
| if category in unique_categories: | ||
| delta.update(20, category.lower() + ' added') | ||
| # no license ==> 'Permissive' or 'Public Domain' | ||
| else: | ||
| delta.update(0, category.lower() + ' added') | ||
| return | ||
| # delta.update(20, 'license info added') | ||
| # | ||
| # for category in new_categories: | ||
| # # no license ==> 'Copyleft Limited'or higher | ||
| # if category in unique_categories: | ||
| # delta.update(20, category.lower() + ' added') | ||
| # # no license ==> 'Permissive' or 'Public Domain' | ||
| # else: | ||
| # delta.update(0, category.lower() + ' added') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here, see above comments |
||
| delta.update(score=20, factor='license info added') | ||
| return | ||
|
|
||
| new_keys = set(license.key for license in new_licenses) | ||
| old_keys = set(license.key for license in old_licenses) | ||
|
|
||
| if new_keys != old_keys: | ||
| delta.update(10, 'license change') | ||
| for category in new_categories - old_categories: | ||
| unique_categories_in_old_file = len(old_categories & unique_categories) | ||
| # 'Permissive' or 'Public Domain' ==> 'Copyleft Limited' or higher | ||
| if unique_categories_in_old_file == 0 and category in unique_categories: | ||
| delta.update(20, category.lower() + ' added') | ||
| # at least 1 category in the old file was 'Copyleft Limited' or higher ==> 'Copyleft Limited' or higher | ||
| elif unique_categories_in_old_file != 0 and category in unique_categories: | ||
| delta.update(10, category.lower() + ' added') | ||
| # 'Permissive' or 'Public Domain' ==> 'Permissive' or 'Public Domain' if not in old_categories | ||
| elif category not in unique_categories: | ||
| delta.update(0, category.lower() + ' added') | ||
| # delta.update(10, 'license change') | ||
| # for category in new_categories - old_categories: | ||
| # unique_categories_in_old_file = len(old_categories & unique_categories) | ||
| # # 'Permissive' or 'Public Domain' ==> 'Copyleft Limited' or higher | ||
| # if unique_categories_in_old_file == 0 and category in unique_categories: | ||
| # delta.update(20, category.lower() + ' added') | ||
| # # at least 1 category in the old file was 'Copyleft Limited' or higher ==> 'Copyleft Limited' or higher | ||
| # elif unique_categories_in_old_file != 0 and category in unique_categories: | ||
| # delta.update(10, category.lower() + ' added') | ||
| # # 'Permissive' or 'Public Domain' ==> 'Permissive' or 'Public Domain' if not in old_categories | ||
| # elif category not in unique_categories: | ||
| # delta.update(0, category.lower() + ' added') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above |
||
| delta.update(score=10, factor='license change') | ||
|
|
||
|
|
||
| def update_from_copyright_info(delta): | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these lines instead of adding comments