Skip to content

Commit 86001b8

Browse files
committed
Merge branch '443_strip_carriage' into develop
2 parents 7ad50d3 + d93b183 commit 86001b8

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

docs/CHANGELOG.rst

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

44
* Add support for `package_url` #396
5+
* Fixed #443 strip carriage return character
56

67
2020-08-11
78
Release 5.0.0

src/attributecode/model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,11 +1064,20 @@ def dumps(self):
10641064
# This line break is for the components that have multiple license
10651065
# values in CSV format.
10661066
if '\n' in field.original_value:
1067-
license_file = field.original_value.split('\n')
1067+
license_file_list = field.original_value.split('\n')
1068+
license_file = []
1069+
# Strip the carriage return character '\r' See #443
1070+
for lic in license_file_list:
1071+
if '\r' in lic:
1072+
license_file.append(lic.strip('\r'))
1073+
else:
1074+
license_file.append(lic)
10681075
else:
10691076
license_file = field.value.keys()
10701077
else:
10711078
license_file = field.value.keys()
1079+
# Strip carriage See #433
1080+
10721081
elif field.name == 'license_url' and field.value:
10731082
license_url = field.value
10741083

tests/test_gen.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,28 @@ def test_generate(self):
193193
)
194194
assert expected == result
195195

196+
def test_generate_multi_lic_issue_443(self):
197+
location = get_test_loc('test_gen/multi_lic_issue_443/test.csv')
198+
base_dir = get_temp_dir()
199+
200+
errors, abouts = gen.generate(location, base_dir)
201+
202+
result = [a.dumps() for a in abouts][0]
203+
expected = (
204+
'''about_resource: test
205+
name: test
206+
version: '1.5'
207+
licenses:
208+
- key: License1
209+
file: LIC1.LICENSE
210+
- key: License2
211+
file: LIC2.LICENSE
212+
- key: License3
213+
file: LIC3.LICENSE
214+
'''
215+
)
216+
assert expected == result
217+
196218
@skip('FIXME: this test is making a failed, live API call')
197219
def test_generate_not_overwrite_original_license_file(self):
198220
location = get_test_loc('test_gen/inv5.csv')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
about_resource,name,version,license_key,license_file
2+
3rdParty/test,test,1.5,"License1
3+
License2
4+
License3","LIC1.LICENSE
5+
LIC2.LICENSE
6+
LIC3.LICENSE"

0 commit comments

Comments
 (0)