Skip to content

Commit d2cb79d

Browse files
committed
Rename method to 'delta.update()' #82 #83
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
1 parent 59b502d commit d2cb79d

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/deltacode/__init__.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,18 @@ def license_diff(self):
199199
old_licenses = delta.old_file.licenses or []
200200

201201
if len(delta.new_file.licenses) > 0 and delta.old_file.licenses == []:
202-
delta.add_score(20, 'license info added')
202+
delta.update(20, 'license info added')
203203
return
204204

205205
if delta.new_file.licenses == [] and len(delta.old_file.licenses) > 0:
206-
delta.add_score(15, 'license info removed')
206+
delta.update(15, 'license info removed')
207207
return
208208

209209
new_keys = set(license.key for license in new_licenses)
210210
old_keys = set(license.key for license in old_licenses)
211211

212212
if new_keys != old_keys:
213-
delta.add_score(10, 'license change')
213+
delta.update(10, 'license change')
214214

215215
def copyright_diff(self):
216216
"""
@@ -228,10 +228,10 @@ def copyright_diff(self):
228228
old_copyrights = delta.old_file.copyrights or []
229229

230230
if len(delta.new_file.copyrights) > 0 and delta.old_file.copyrights == []:
231-
delta.add_score(10, 'copyright info added')
231+
delta.update(10, 'copyright info added')
232232
return
233233
elif delta.new_file.copyrights == [] and len(delta.old_file.copyrights) > 0:
234-
delta.add_score(10, 'copyright info removed')
234+
delta.update(10, 'copyright info removed')
235235
return
236236

237237
new_statements = set(statement for copyright in new_copyrights for statement in copyright.statements)
@@ -242,7 +242,7 @@ def copyright_diff(self):
242242

243243
if ((new_statements != old_statements) or
244244
(new_holders != old_holders)):
245-
delta.add_score(5, 'copyright change')
245+
delta.update(5, 'copyright change')
246246

247247
def index_deltas(self, index_key='path', delta_list=[]):
248248
"""
@@ -280,12 +280,11 @@ def __init__(self, score=0, new_file=None, old_file=None):
280280
self.factors = []
281281
self.score = score
282282

283-
def add_score(self, score=0, factor=''):
283+
def update(self, score=0, factor=''):
284284
"""
285-
For each Delta object identified in DeltaCode.license_diff() or
286-
DeltaCode.copyright_diff(), add the score to the object's 'score'
287-
attribute and add a string, summarizing the factor associated with the
288-
score, to the object's 'factors' attribute (a list).
285+
Add the score to the Delta object's 'score' attribute and add a string,
286+
summarizing the factor associated with the score, to the object's
287+
'factors' attribute (a list).
289288
"""
290289
self.factors.append(factor)
291290
self.score += score

tests/test_deltacode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ def test_Delta_add_score_added(self):
16611661

16621662
delta = deltacode.Delta(100, new, None)
16631663

1664-
delta.add_score(25, 'This is a test of an added file')
1664+
delta.update(25, 'This is a test of an added file')
16651665

16661666
assert delta.score == 125
16671667
assert delta.factors == ['This is a test of an added file']
@@ -1686,7 +1686,7 @@ def test_Delta_add_score_modified(self):
16861686

16871687
delta = deltacode.Delta(20, new, old)
16881688

1689-
delta.add_score(25, 'This is a test of a modified file')
1689+
delta.update(25, 'This is a test of a modified file')
16901690

16911691
assert delta.score == 45
16921692
assert delta.factors == ['This is a test of a modified file']
@@ -1708,7 +1708,7 @@ def test_Delta_add_score_license_change_no_copyright_change(self):
17081708

17091709
for d in deltas_object:
17101710
if d.new_file.path == 'path.txt':
1711-
d.add_score(25, 'This is a test of a license change')
1711+
d.update(25, 'This is a test of a license change')
17121712

17131713
assert [d.score for d in deltas_object if d.new_file.path == 'path.txt'] == [55]
17141714
assert [d.factors for d in deltas_object if d.new_file.path == 'path.txt'].pop() == ['modified', 'license change', 'This is a test of a license change']

0 commit comments

Comments
 (0)