Skip to content
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: 0 additions & 2 deletions etc/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ def save_activate_this_py_script(activate_path):
print('ERROR: unknown option: %(arg0)s' % locals())
print(usage)
sys.exit(1)

sys.path.insert(0, root_dir)
bin_dir = os.path.join(root_dir, 'bin')
standard_python = sys.executable
Expand Down Expand Up @@ -565,7 +564,6 @@ def save_activate_this_py_script(activate_path):
create_virtualenv = create_virtualenv_py2
else:
create_virtualenv = create_virtualenv_py3

# Finally execute our three steps: venv, install and scripts
if not os.path.exists(configured_python):
create_virtualenv(standard_python, root_dir, thirdparty_dirs, quiet=quiet)
Expand Down
2 changes: 2 additions & 0 deletions src/deltacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ class Delta(object):
def __init__(self, score=0, new_file=None, old_file=None):
self.new_file = new_file if new_file else None
self.old_file = old_file if old_file else None
self.has_license = False
self.has_copyright = False
Comment on lines +286 to +287

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaJuRG I provided it as attributes of every delta objects,as we can just check these booleans for determining weather the respective deltas has a license or copyright(either new or old file)
Depending on these booleans we can actually use the license Expression Library

self.factors = []
self.score = score
self.status = ''
Expand Down
14 changes: 14 additions & 0 deletions src/deltacode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ def update_from_license_info(delta, unique_categories):
one or more appropriate categories to its 'factors' attribute if there has
been a license change and depending on the nature of that change.
"""

if delta.new_file:
if delta.new_file.has_licenses():
delta.has_licenses = True
if delta.old_file:
if delta.old_file.has_licenses():
delta.has_licenses = True

if delta.is_added():
update_added_from_license_info(delta, unique_categories)

Expand Down Expand Up @@ -121,6 +129,12 @@ def update_from_copyright_info(delta):
one or more appropriate categories to its 'factors' attribute if there has
been a copyright change and depending on the nature of that change.
"""
if delta.new_file:
if delta.new_file.has_copyrights():
delta.has_copyrights = True
if delta.old_file:
if delta.old_file.has_copyrights():
delta.has_copyrights = True
if delta.is_added():
update_added_from_copyright_info(delta)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_deltacode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,20 +1645,20 @@ def test_similarity_matching_1(self):
result_file = self.get_temp_file('json')
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
test_utils.run_scan_click(args)
test_utils.check_json_scan(self.get_test_loc('deltacode/coala-expected-result.json'), result_file, regen=True)
test_utils.check_json_scan(self.get_test_loc('deltacode/coala-expected-result.json'), result_file, regen=False)

def test_similarity_matching_2(self):
old_file = self.get_test_loc('deltacode/sugar-0.108.0-old.json')
new_file = self.get_test_loc('deltacode/sugar-0.114-new.json')
result_file = self.get_temp_file('json')
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
test_utils.run_scan_click(args)
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-expected.json'), result_file, regen=True)
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-expected.json'), result_file, regen=False)

def test_non_similarity_matching_1(self):
old_file = self.get_test_loc('deltacode/coala-0.7.0-old.json')
new_file = self.get_test_loc('deltacode/sugar-0.114-new.json')
result_file = self.get_temp_file('json')
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
test_utils.run_scan_click(args)
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-coala-expected.json'), result_file, regen=True)
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-coala-expected.json'), result_file, regen=False)