Skip to content

Commit 2835675

Browse files
committed
Fixed #444 - Bug for single license with multi files
1 parent 86001b8 commit 2835675

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

docs/CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Release 5.1.0
33

44
* Add support for `package_url` #396
5-
* Fixed #443 strip carriage return character
5+
* Fixed #443 and #444 issue with multiple licenses/license_files
66

77
2020-08-11
88
Release 5.0.0

src/attributecode/model.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,14 @@ def dumps(self):
10731073
else:
10741074
license_file.append(lic)
10751075
else:
1076-
license_file = field.value.keys()
1076+
if isinstance(field.original_value, list):
1077+
license_file = field.value.keys()
1078+
else:
1079+
# Restore the original license_file value
1080+
# See #444
1081+
license_file = [field.original_value]
10771082
else:
10781083
license_file = field.value.keys()
1079-
# Strip carriage See #433
1080-
10811084
elif field.name == 'license_url' and field.value:
10821085
license_url = field.value
10831086

tests/test_gen.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ def test_generate_multi_lic_issue_443(self):
215215
)
216216
assert expected == result
217217

218+
def test_generate_multi_lic_issue_444(self):
219+
location = get_test_loc('test_gen/multi_lic_issue_444/test1.csv')
220+
base_dir = get_temp_dir()
221+
222+
errors, abouts = gen.generate(location, base_dir)
223+
224+
result = [a.dumps() for a in abouts][0]
225+
expected = (
226+
'''about_resource: test.c
227+
name: test.c
228+
licenses:
229+
- key: License1
230+
file: LIC1.LICENSE, LIC2.LICENSE
231+
'''
232+
)
233+
assert expected == result
234+
218235
@skip('FIXME: this test is making a failed, live API call')
219236
def test_generate_not_overwrite_original_license_file(self):
220237
location = get_test_loc('test_gen/inv5.csv')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
about_resource,name,license_key,license_file
2+
3rdParty/test.c,test.c,License1,"LIC1.LICENSE, LIC2.LICENSE"

0 commit comments

Comments
 (0)