Skip to content

Commit 3d1d18e

Browse files
committed
Fixed based on 9de0718
1 parent 1fdca4e commit 3d1d18e

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/attributecode/gen.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@ def check_newline_in_file_field(component):
9696
if k in file_fields:
9797
try:
9898
if '\n' in component[k]:
99-
msg = ("New line character detected in '%s' for '%s' which is not supported."
100-
"\nPlease use ',' to declare multiple files.") % (k, component['about_resource'])
99+
if k == u'about_resource':
100+
msg = (
101+
"New line character detected in 'about_resource' for '%s' which is not supported.") % component['about_resource']
102+
else:
103+
msg = ("New line character detected in '%s' for '%s' which is not supported."
104+
"\nPlease use ',' to declare multiple files.") % (k, component['about_resource'])
101105
errors.append(Error(CRITICAL, msg))
102106
except:
103107
pass
@@ -111,7 +115,7 @@ def check_about_resource_filename(arp):
111115
"""
112116
if invalid_chars(arp):
113117
msg = ("Invalid characters present in 'about_resource' "
114-
"field: " + arp)
118+
"field: " + arp)
115119
return (Error(ERROR, msg))
116120
return ''
117121

@@ -185,7 +189,8 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
185189
if from_attrib and f == 'about_resource':
186190
continue
187191
else:
188-
msg = "Required field: %(f)r not found in the <input>" % locals()
192+
msg = "Required field: %(f)r not found in the <input>" % locals(
193+
)
189194
errors.append(Error(CRITICAL, msg))
190195
return errors, abouts
191196
# Set about file path to '' if no 'about_resource' is provided from
@@ -245,7 +250,8 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
245250

246251
abouts.append(about)
247252
if custom_fields_list:
248-
custom_fields_err_msg = 'Field ' + str(custom_fields_list) + ' is a custom field.'
253+
custom_fields_err_msg = 'Field ' + \
254+
str(custom_fields_list) + ' is a custom field.'
249255
errors.append(Error(INFO, custom_fields_err_msg))
250256
# Covert the license_score value from string to list of int
251257
# The licesne_score is not in the spec but is specify in the scancode license scan.
@@ -254,7 +260,8 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
254260
if scancode:
255261
for about in abouts:
256262
try:
257-
score_list = list(map(float, about.license_score.value.replace('[', '').replace(']', '').split(',')))
263+
score_list = list(map(float, about.license_score.value.replace(
264+
'[', '').replace(']', '').split(',')))
258265
about.license_score.value = score_list
259266
except:
260267
pass
@@ -297,7 +304,8 @@ def generate(location, base_dir, android=None, reference_dir=None, fetch_license
297304
)
298305

299306
if gen_license:
300-
license_dict, err = model.pre_process_and_fetch_license_dict(abouts, api_url, api_key)
307+
license_dict, err = model.pre_process_and_fetch_license_dict(
308+
abouts, api_url, api_key)
301309
if err:
302310
for e in err:
303311
# Avoid having same error multiple times
@@ -343,7 +351,8 @@ def generate(location, base_dir, android=None, reference_dir=None, fetch_license
343351
# be validated when creating the about object
344352
loc = util.to_posix(dump_loc)
345353
about_file_loc = loc
346-
path = join(dirname(util.to_posix(about_file_loc)), about_resource_value)
354+
path = join(dirname(util.to_posix(about_file_loc)),
355+
about_resource_value)
347356
if not exists(path):
348357
path = util.to_posix(path.strip(UNC_PREFIX_POSIX))
349358
path = normpath(path)
@@ -355,10 +364,12 @@ def generate(location, base_dir, android=None, reference_dir=None, fetch_license
355364
licenses_dict = {}
356365
if gen_license:
357366
# Write generated LICENSE file
358-
license_key_name_context_url_list = about.dump_lic(dump_loc, license_dict)
367+
license_key_name_context_url_list = about.dump_lic(
368+
dump_loc, license_dict)
359369
if license_key_name_context_url_list:
360370
for lic_key, lic_name, lic_filename, lic_context, lic_url, spdx_lic_key in license_key_name_context_url_list:
361-
licenses_dict[lic_key] = [lic_name, lic_filename, lic_context, lic_url, spdx_lic_key]
371+
licenses_dict[lic_key] = [
372+
lic_name, lic_filename, lic_context, lic_url, spdx_lic_key]
362373
if not lic_name in about.license_name.value:
363374
about.license_name.value.append(lic_name)
364375
about.license_file.value[lic_filename] = lic_filename

0 commit comments

Comments
 (0)