diff --git a/about_code_tool/genabout.py b/about_code_tool/genabout.py index 731cb508..f20d81ac 100644 --- a/about_code_tool/genabout.py +++ b/about_code_tool/genabout.py @@ -338,7 +338,7 @@ def pre_process_and_dje_license_dict(self, input_list, api_url, api_username, ap try: if line['dje_license']: detail = self.get_license_details_from_api(api_url, api_username, api_key, line['dje_license']) - line['dje_license_name'], key_text_dict[line['dje_license']] = detail + line['dje_license_name'], key_text_dict[line['dje_license_name']] = detail except Exception as e: self.warnings.append(Warn('dje_license', '', "Missing 'dje_license' for " + line['about_file'])) @@ -404,13 +404,13 @@ def pre_generation(self, gen_location, input_list, action_num, all_in_one): @staticmethod def gen_license_list(line): - dje_key = line['dje_license'] + dje_license_name = line['dje_license_name'] file_location = line['about_file'] if file_location.endswith('/'): file_location = file_location.rpartition('/')[0] about_parent_dir = dirname(file_location) - line['license_text_file'] = dje_key +'.LICENSE' - return (about_parent_dir, dje_key) + line['license_text_file'] = dje_license_name +'.LICENSE' + return (about_parent_dir, dje_license_name) @staticmethod def format_output(input_list): @@ -675,23 +675,24 @@ def main(parser, options, args): print("The input does not have the 'dje_license' key which is required.") sys.exit(errno.EINVAL) - dje_license_list = gen.get_dje_license_list(output_path, input_list, gen_license) - - # The dje_license_list is an empty list if gen_license is 'False' if gen_license: dje_license_dict = gen.pre_process_and_dje_license_dict(input_list, api_url, api_username, api_key) - license_list_context = gen.process_dje_licenses(dje_license_list, - dje_license_dict, - output_path) - gen.write_licenses(license_list_context) + + dje_license_list = gen.get_dje_license_list(output_path, input_list, gen_license) components_list = gen.pre_generation(output_path, input_list, action_num, all_in_one) formatted_output = gen.format_output(components_list) gen.write_output(formatted_output) + if dje_license_list: + license_list_context = gen.process_dje_licenses(dje_license_list, + dje_license_dict, + output_path) + gen.write_licenses(license_list_context) + gen.warnings_errors_summary() print('Warnings: %s' % len(gen.warnings)) print('Errors: %s' % len(gen.errors)) diff --git a/about_code_tool/tests/test_genabout.py b/about_code_tool/tests/test_genabout.py index ca71d0d3..21ba4835 100644 --- a/about_code_tool/tests/test_genabout.py +++ b/about_code_tool/tests/test_genabout.py @@ -231,8 +231,9 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_empty_license_tex gen_location = join(TESTDATA_PATH, "test_files_for_genabout/") input_list = [{'about_file': '/about.py.ABOUT', 'version': '0.8.1', 'about_resource': '.', 'name': 'ABOUT tool', + 'dje_license_name': 'Apache License 2.0', 'license_text_file': '', 'dje_license': 'apache-2.0'}] - expected_output_list = [('/', 'apache-2.0')] + expected_output_list = [('/', 'Apache License 2.0')] gen_license = True lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license) 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 gen_location = join(TESTDATA_PATH, "test_files_for_genabout/") input_list = [{'about_file': '/about.py.ABOUT', 'version': '0.8.1', 'about_resource': '.', 'name': 'ABOUT tool', + 'dje_license_name': 'Apache License 2.0', 'dje_license': 'apache-2.0'}] - expected_output_list = [('/', 'apache-2.0')] + expected_output_list = [('/', 'Apache License 2.0')] gen_license = True lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license) self.assertTrue(expected_output_list == lic_output_list) @@ -434,21 +436,23 @@ def test_gen_license_list_license_text_file_no_value(self): gen = genabout.GenAbout() input_list = {'about_file': '/tmp/3pp/opensans/', 'name': 'OpenSans Fonts', 'version': '1', 'dje_license': 'apache-2.0', + 'dje_license_name': 'Apache License 2.0', 'license_text_file': '', 'about_resource': 'opensans'} - expected_list = ('/tmp/3pp', 'apache-2.0') + expected_list = ('/tmp/3pp', 'Apache License 2.0') output = gen.gen_license_list(input_list) self.assertTrue(expected_list == output) - self.assertTrue(input_list['license_text_file'] == 'apache-2.0.LICENSE') + self.assertTrue(input_list['license_text_file'] == 'Apache License 2.0.LICENSE') def test_gen_license_list_no_license_text_file_key(self): gen = genabout.GenAbout() input_list = {'about_file': '/tmp/3pp/opensans/', 'name': 'OpenSans Fonts', 'version': '1', 'dje_license': 'apache-2.0', + 'dje_license_name': 'Apache License 2.0', 'about_resource': 'opensans'} - expected_list = ('/tmp/3pp', 'apache-2.0') + expected_list = ('/tmp/3pp', 'Apache License 2.0') output = gen.gen_license_list(input_list) self.assertTrue(expected_list == output) - self.assertTrue(input_list['license_text_file'] == 'apache-2.0.LICENSE') + self.assertTrue(input_list['license_text_file'] == 'Apache License 2.0.LICENSE') def test_copy_license_files_test_path_not_endswith_slash(self): gen = genabout.GenAbout()