Skip to content

Commit 4c2db1c

Browse files
committed
Fixed #93
Use 'dje_license_name' as the value of the 'licesen_text_file'
1 parent 92d3d84 commit 4c2db1c

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

about_code_tool/genabout.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def pre_process_and_dje_license_dict(self, input_list, api_url, api_username, ap
338338
try:
339339
if line['dje_license']:
340340
detail = self.get_license_details_from_api(api_url, api_username, api_key, line['dje_license'])
341-
line['dje_license_name'], key_text_dict[line['dje_license']] = detail
341+
line['dje_license_name'], key_text_dict[line['dje_license_name']] = detail
342342
except Exception as e:
343343
self.warnings.append(Warn('dje_license', '',
344344
"Missing 'dje_license' for " + line['about_file']))
@@ -404,13 +404,13 @@ def pre_generation(self, gen_location, input_list, action_num, all_in_one):
404404

405405
@staticmethod
406406
def gen_license_list(line):
407-
dje_key = line['dje_license']
407+
dje_license_name = line['dje_license_name']
408408
file_location = line['about_file']
409409
if file_location.endswith('/'):
410410
file_location = file_location.rpartition('/')[0]
411411
about_parent_dir = dirname(file_location)
412-
line['license_text_file'] = dje_key +'.LICENSE'
413-
return (about_parent_dir, dje_key)
412+
line['license_text_file'] = dje_license_name +'.LICENSE'
413+
return (about_parent_dir, dje_license_name)
414414

415415
@staticmethod
416416
def format_output(input_list):
@@ -675,23 +675,24 @@ def main(parser, options, args):
675675
print("The input does not have the 'dje_license' key which is required.")
676676
sys.exit(errno.EINVAL)
677677

678-
dje_license_list = gen.get_dje_license_list(output_path, input_list, gen_license)
679-
680-
# The dje_license_list is an empty list if gen_license is 'False'
681678
if gen_license:
682679
dje_license_dict = gen.pre_process_and_dje_license_dict(input_list,
683680
api_url,
684681
api_username,
685682
api_key)
686-
license_list_context = gen.process_dje_licenses(dje_license_list,
687-
dje_license_dict,
688-
output_path)
689-
gen.write_licenses(license_list_context)
683+
684+
dje_license_list = gen.get_dje_license_list(output_path, input_list, gen_license)
690685

691686
components_list = gen.pre_generation(output_path, input_list, action_num, all_in_one)
692687
formatted_output = gen.format_output(components_list)
693688
gen.write_output(formatted_output)
694689

690+
if dje_license_list:
691+
license_list_context = gen.process_dje_licenses(dje_license_list,
692+
dje_license_dict,
693+
output_path)
694+
gen.write_licenses(license_list_context)
695+
695696
gen.warnings_errors_summary()
696697
print('Warnings: %s' % len(gen.warnings))
697698
print('Errors: %s' % len(gen.errors))

about_code_tool/tests/test_genabout.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_empty_license_tex
231231
gen_location = join(TESTDATA_PATH, "test_files_for_genabout/")
232232
input_list = [{'about_file': '/about.py.ABOUT', 'version': '0.8.1',
233233
'about_resource': '.', 'name': 'ABOUT tool',
234+
'dje_license_name': 'Apache License 2.0',
234235
'license_text_file': '', 'dje_license': 'apache-2.0'}]
235-
expected_output_list = [('/', 'apache-2.0')]
236+
expected_output_list = [('/', 'Apache License 2.0')]
236237
gen_license = True
237238
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license)
238239
self.assertTrue(expected_output_list == lic_output_list)
@@ -257,8 +258,9 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_no_license_text_f
257258
gen_location = join(TESTDATA_PATH, "test_files_for_genabout/")
258259
input_list = [{'about_file': '/about.py.ABOUT', 'version': '0.8.1',
259260
'about_resource': '.', 'name': 'ABOUT tool',
261+
'dje_license_name': 'Apache License 2.0',
260262
'dje_license': 'apache-2.0'}]
261-
expected_output_list = [('/', 'apache-2.0')]
263+
expected_output_list = [('/', 'Apache License 2.0')]
262264
gen_license = True
263265
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license)
264266
self.assertTrue(expected_output_list == lic_output_list)
@@ -434,21 +436,23 @@ def test_gen_license_list_license_text_file_no_value(self):
434436
gen = genabout.GenAbout()
435437
input_list = {'about_file': '/tmp/3pp/opensans/', 'name': 'OpenSans Fonts',
436438
'version': '1', 'dje_license': 'apache-2.0',
439+
'dje_license_name': 'Apache License 2.0',
437440
'license_text_file': '', 'about_resource': 'opensans'}
438-
expected_list = ('/tmp/3pp', 'apache-2.0')
441+
expected_list = ('/tmp/3pp', 'Apache License 2.0')
439442
output = gen.gen_license_list(input_list)
440443
self.assertTrue(expected_list == output)
441-
self.assertTrue(input_list['license_text_file'] == 'apache-2.0.LICENSE')
444+
self.assertTrue(input_list['license_text_file'] == 'Apache License 2.0.LICENSE')
442445

443446
def test_gen_license_list_no_license_text_file_key(self):
444447
gen = genabout.GenAbout()
445448
input_list = {'about_file': '/tmp/3pp/opensans/', 'name': 'OpenSans Fonts',
446449
'version': '1', 'dje_license': 'apache-2.0',
450+
'dje_license_name': 'Apache License 2.0',
447451
'about_resource': 'opensans'}
448-
expected_list = ('/tmp/3pp', 'apache-2.0')
452+
expected_list = ('/tmp/3pp', 'Apache License 2.0')
449453
output = gen.gen_license_list(input_list)
450454
self.assertTrue(expected_list == output)
451-
self.assertTrue(input_list['license_text_file'] == 'apache-2.0.LICENSE')
455+
self.assertTrue(input_list['license_text_file'] == 'Apache License 2.0.LICENSE')
452456

453457
def test_copy_license_files_test_path_not_endswith_slash(self):
454458
gen = genabout.GenAbout()

0 commit comments

Comments
 (0)