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

Added has_license and has_copyright to delta object #114

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/deltacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ def __init__(self, score=0, new_file=None, old_file=None):
self.old_file = old_file if old_file else None
self.factors = []
self.score = score
self.has_license = False
self.has_copyright = False

def update(self, score=0, factor=''):
"""
Expand Down
12 changes: 6 additions & 6 deletions src/deltacode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def update_added_from_license_info(delta, unique_categories):
new_categories = set(license.category for license in new_licenses)

if delta.new_file.has_licenses():
delta.update(20, 'license info added')
delta.has_license = True

for category in new_categories:
# no license ==> 'Copyleft Limited'or higher
Expand All @@ -75,7 +75,7 @@ def update_modified_from_license_info(delta, unique_categories):
been a license change.
"""
if not delta.new_file.has_licenses() and delta.old_file.has_licenses():
delta.update(15, 'license info removed')
delta.has_license = False
return

new_licenses = delta.new_file.licenses or []
Expand All @@ -85,7 +85,7 @@ def update_modified_from_license_info(delta, unique_categories):
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')
delta.has_license = True

for category in new_categories:
# no license ==> 'Copyleft Limited'or higher
Expand Down Expand Up @@ -134,7 +134,7 @@ def update_added_from_copyright_info(delta):
been a copyright change.
"""
if delta.new_file.has_copyrights():
delta.update(10, 'copyright info added')
delta.has_copyright = True
return


Expand All @@ -148,10 +148,10 @@ def update_modified_from_copyright_info(delta):
old_copyrights = delta.old_file.copyrights or []

if delta.new_file.has_copyrights() and not delta.old_file.has_copyrights():
delta.update(10, 'copyright info added')
delta.has_copyright = True
return
if not delta.new_file.has_copyrights() and delta.old_file.has_copyrights():
delta.update(10, 'copyright info removed')
delta.has_copyright = False
return

new_holders = set(holder for copyright in new_copyrights for holder in copyright.holders)
Expand Down