From 18ec9a68835ac77ead19a54d32066afbaec2c51c Mon Sep 17 00:00:00 2001 From: Shubham Date: Fri, 22 Mar 2019 13:51:31 +0530 Subject: [PATCH] Add has_license / has_copyright to delta object #109 Update has_license and has_copyright appropriately Signed-off-by: Shubham --- src/deltacode/__init__.py | 2 ++ src/deltacode/utils.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/deltacode/__init__.py b/src/deltacode/__init__.py index 2c08f279..66058b16 100644 --- a/src/deltacode/__init__.py +++ b/src/deltacode/__init__.py @@ -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=''): """ diff --git a/src/deltacode/utils.py b/src/deltacode/utils.py index 2e6e5073..eb243dfa 100644 --- a/src/deltacode/utils.py +++ b/src/deltacode/utils.py @@ -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 @@ -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 [] @@ -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 @@ -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 @@ -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)