Skip to content

Commit fbae501

Browse files
committed
Added has copyright and has license attribute to delta objects
1 parent de61d43 commit fbae501

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

etc/configure.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ def save_activate_this_py_script(activate_path):
508508
print('ERROR: unknown option: %(arg0)s' % locals())
509509
print(usage)
510510
sys.exit(1)
511-
512511
sys.path.insert(0, root_dir)
513512
bin_dir = os.path.join(root_dir, 'bin')
514513
standard_python = sys.executable
@@ -565,7 +564,6 @@ def save_activate_this_py_script(activate_path):
565564
create_virtualenv = create_virtualenv_py2
566565
else:
567566
create_virtualenv = create_virtualenv_py3
568-
569567
# Finally execute our three steps: venv, install and scripts
570568
if not os.path.exists(configured_python):
571569
create_virtualenv(standard_python, root_dir, thirdparty_dirs, quiet=quiet)

src/deltacode/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,17 @@ class Delta(object):
283283
def __init__(self, score=0, new_file=None, old_file=None):
284284
self.new_file = new_file if new_file else None
285285
self.old_file = old_file if old_file else None
286+
self.has_license = False
287+
self.has_copyright = False
286288
self.factors = []
287289
self.score = score
288290
self.status = ''
291+
292+
def add_license(self) :
293+
self.has_license = True
294+
295+
def add_copyright(self):
296+
self.has_copyright = True
289297

290298
def update(self, score=0, factor=''):
291299
"""

src/deltacode/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def update_from_license_info(delta, unique_categories):
4040
one or more appropriate categories to its 'factors' attribute if there has
4141
been a license change and depending on the nature of that change.
4242
"""
43+
44+
if delta.new_file:
45+
if delta.new_file.has_licenses():
46+
delta.add_license()
47+
if delta.old_file:
48+
if delta.old_file.has_licenses():
49+
delta.add_license()
50+
4351
if delta.is_added():
4452
update_added_from_license_info(delta, unique_categories)
4553

@@ -121,6 +129,12 @@ def update_from_copyright_info(delta):
121129
one or more appropriate categories to its 'factors' attribute if there has
122130
been a copyright change and depending on the nature of that change.
123131
"""
132+
if delta.new_file:
133+
if delta.new_file.has_copyrights():
134+
delta.add_copyright()
135+
if delta.old_file:
136+
if delta.old_file.has_copyrights():
137+
delta.add_copyright()
124138
if delta.is_added():
125139
update_added_from_copyright_info(delta)
126140

tests/test_deltacode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,20 +1645,20 @@ def test_similarity_matching_1(self):
16451645
result_file = self.get_temp_file('json')
16461646
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
16471647
test_utils.run_scan_click(args)
1648-
test_utils.check_json_scan(self.get_test_loc('deltacode/coala-expected-result.json'), result_file, regen=True)
1648+
test_utils.check_json_scan(self.get_test_loc('deltacode/coala-expected-result.json'), result_file, regen=False)
16491649

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

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

0 commit comments

Comments
 (0)