Skip to content

Commit

Permalink
Added has_license and has_copyright to delta object
Browse files Browse the repository at this point in the history
Update has_license and has_copyright appropriately

Signed-off-by: Shubham Sangamnerkar <shubhamsangamnerkar9@gmail.com>
  • Loading branch information
shubhscoder committed Mar 22, 2019
1 parent e9cdf8e commit aec399a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit aec399a

Please sign in to comment.