-
-
Notifications
You must be signed in to change notification settings - Fork 27
Add Copyright class and copyright_diff() #82 #83 #85
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00b6e7a
Add 'Copyright' class #82
johnmhoran f8f5861
Add copyright_diff() to DeltaCode object #83
johnmhoran f1c9f4d
Add additional copyright-related tests #83
johnmhoran 59b502d
Refactor copyright-related code #82 #83
johnmhoran d2cb79d
Rename method to 'delta.update()' #82 #83
johnmhoran 195eb00
Test copyrights for unusual characters #82 #83
johnmhoran 4199bcd
Remove print statements #82 #83
johnmhoran 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
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
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Factors,Score,Path,Name,Type,Size,Old Path | ||
| modified license info added copyright info added,50,path.txt,path.txt,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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", | ||
| "scancode_version": "2.1.0", | ||
| "scancode_options": { | ||
| "--license": true, | ||
| "--info": true | ||
| }, | ||
| "files_count": 2, | ||
| "files": [ | ||
| { | ||
| "path": "new/default.txt", | ||
| "type": "file", | ||
| "name": "default.txt", | ||
| "size": 100, | ||
| "sha1": "a", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| }, | ||
| { | ||
| "path": "new/path.txt", | ||
| "type": "file", | ||
| "name": "path.txt", | ||
| "size": 300, | ||
| "sha1": "b_modified", | ||
| "licenses": [ | ||
| { | ||
| "key": "gpl-1.0-plus", | ||
| "score": 20.0, | ||
| "short_name": "GPL 1.0 or later", | ||
| "category": "Copyleft", | ||
| "owner": "Free Software Foundation (FSF)", | ||
| "homepage_url": "http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html", | ||
| "text_url": "http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html", | ||
| "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:gpl-1.0-plus", | ||
| "spdx_license_key": "GPL-1.0+", | ||
| "spdx_url": "https://spdx.org/licenses/GPL-1.0", | ||
| "start_line": 353, | ||
| "end_line": 353, | ||
| "matched_rule": { | ||
| "identifier": "gpl_63.RULE", | ||
| "license_choice": false, | ||
| "licenses": [ | ||
| "gpl-1.0-plus" | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "copyrights": [ | ||
| { | ||
| "statements": [ | ||
| "Copyright (c) 2016 Mark Adler" | ||
| ], | ||
| "holders": [ | ||
| "Mark Adler" | ||
| ], | ||
| "authors": [], | ||
| "start_line": 1, | ||
| "end_line": 3 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", | ||
| "scancode_version": "2.1.0", | ||
| "scancode_options": { | ||
| "--license": true, | ||
| "--info": true | ||
| }, | ||
| "files_count": 2, | ||
| "files": [ | ||
| { | ||
| "path": "old/default.txt", | ||
| "type": "file", | ||
| "name": "default.txt", | ||
| "size": 100, | ||
| "sha1": "a", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| }, | ||
| { | ||
| "path": "old/path.txt", | ||
| "type": "file", | ||
| "name": "path.txt", | ||
| "size": 300, | ||
| "sha1": "b", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| } | ||
| ] | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Factors,Score,Path,Name,Type,Size,Old Path | ||
| modified license info removed copyright info removed,45,path.txt,path.txt,file,300, |
29 changes: 29 additions & 0 deletions
29
tests/data/cli/copyright_and_license_info_removed_new.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", | ||
| "scancode_version": "2.1.0", | ||
| "scancode_options": { | ||
| "--license": true, | ||
| "--info": true | ||
| }, | ||
| "files_count": 2, | ||
| "files": [ | ||
| { | ||
| "path": "new/default.txt", | ||
| "type": "file", | ||
| "name": "default.txt", | ||
| "size": 100, | ||
| "sha1": "a", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| }, | ||
| { | ||
| "path": "new/path.txt", | ||
| "type": "file", | ||
| "name": "path.txt", | ||
| "size": 300, | ||
| "sha1": "b_modified", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| } | ||
| ] | ||
| } |
63 changes: 63 additions & 0 deletions
63
tests/data/cli/copyright_and_license_info_removed_old.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "scancode_notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", | ||
| "scancode_version": "2.1.0", | ||
| "scancode_options": { | ||
| "--license": true, | ||
| "--info": true | ||
| }, | ||
| "files_count": 2, | ||
| "files": [ | ||
| { | ||
| "path": "old/default.txt", | ||
| "type": "file", | ||
| "name": "default.txt", | ||
| "size": 100, | ||
| "sha1": "a", | ||
| "licenses": [], | ||
| "copyrights": [] | ||
| }, | ||
| { | ||
| "path": "old/path.txt", | ||
| "type": "file", | ||
| "name": "path.txt", | ||
| "size": 300, | ||
| "sha1": "b", | ||
| "licenses": [ | ||
| { | ||
| "key": "gpl-1.0-plus", | ||
| "score": 20.0, | ||
| "short_name": "GPL 1.0 or later", | ||
| "category": "Copyleft", | ||
| "owner": "Free Software Foundation (FSF)", | ||
| "homepage_url": "http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html", | ||
| "text_url": "http://www.gnu.org/licenses/old-licenses/gpl-1.0-standalone.html", | ||
| "reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:gpl-1.0-plus", | ||
| "spdx_license_key": "GPL-1.0+", | ||
| "spdx_url": "https://spdx.org/licenses/GPL-1.0", | ||
| "start_line": 353, | ||
| "end_line": 353, | ||
| "matched_rule": { | ||
| "identifier": "gpl_63.RULE", | ||
| "license_choice": false, | ||
| "licenses": [ | ||
| "gpl-1.0-plus" | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "copyrights": [ | ||
| { | ||
| "statements": [ | ||
| "Copyright (c) 2016 Mark Adler" | ||
| ], | ||
| "holders": [ | ||
| "Mark Adler" | ||
| ], | ||
| "authors": [], | ||
| "start_line": 1, | ||
| "end_line": 3 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Factors,Score,Path,Name,Type,Size,Old Path | ||
| modified copyright change,25,path.txt,path.txt,file,300, |
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.
If you haven’t already, you should add tests cases where a files have large numbers of copyrights holders and statements to see if we choke somewhere, espically in the output
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.
Also tests where there are strange characters or accent marks in the copyright statements/holders.
All of these additional test cases I mentioned should probably come from scancode generated output directly as opposed to crafting the test object by hand.
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.
@MaJuRG Since we want to use ScanCode-generated output, do you have any codebases in mind that satisfy the characteristics you describe?
I've started to work my way through the codebases we've worked with (openssl, zlib et al.) but I've not yet seen large numbers of copyright holders/statements or unusual characters.
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.
@johnmhoran You will probably just have to hand-create a file or files that contain a bunch of copyright statements
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.
OK. Thanks, @MaJuRG .
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.
@MaJuRG I'm finding that an error is thrown when I include a French accent character in the copyright
statementsorholdersvalue, e.g.,"é". The error is thrown even if I comment out the character (presumably because even comments are parsed). Unicode and UTF-8 do not throw an error.SyntaxError: Non-ASCII character '\xc3' in file C:\code\nexb\dev\deltacode\tests\test_models.py on line 1073, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for detailsWhile PEP 263 gives some suggestions, it's not clear to me how we can apply these to handle our input. I've done some searching in the ScanCode repo -- surely ScanCode must be able to handle such characters -- but have not yet found how ScanCode addresses this.
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.
Looks like this issue might be addressed in scancode-toolkit/src/commoncode/text.py?
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.
@johnmhoran where is this "statements" located?
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.
@MaJuRG Per your suggestion above, I'm hand-crafting old and new files in a new test,
test_Copyright_unusual_characters(), intest_models.py.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.
@MaJuRG Would it be easier for you if I commit and push? Except for this one failing test, it's ready for your review.