From df080f326bc54ac1f4321c8ee2bce0435d962c39 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Tue, 1 Jul 2014 10:04:42 -0700 Subject: [PATCH] Fixed #109 Put the ABOUT file INSIDE of a directory if this ABOUT file reference the directory and update the 'about_resource' to '.' (period) as a meaning that this ABOUT file is referencing everything in the current directory. --- about_code_tool/genabout.py | 6 +++++- about_code_tool/tests/test_genabout.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/about_code_tool/genabout.py b/about_code_tool/genabout.py index 780c9249..7d849e0b 100644 --- a/about_code_tool/genabout.py +++ b/about_code_tool/genabout.py @@ -388,7 +388,11 @@ def pre_generation(self, gen_location, input_list, action_num, all_in_one): file_location = file_location.partition('/')[2] if not file_location.endswith('.ABOUT'): if file_location.endswith('/'): - file_location = file_location.rpartition('/')[0] + file_location = dirname(file_location) + file_location = join(file_location, os.path.basename(file_location)) + # Since this is referencing everything in the current directory, + # we will use a '.' period to reference it. + line['about_resource'] = '.' file_location += '.ABOUT' if all_in_one: # This is to get the filename instead of the file path diff --git a/about_code_tool/tests/test_genabout.py b/about_code_tool/tests/test_genabout.py index d7f0443a..a32b7cd5 100644 --- a/about_code_tool/tests/test_genabout.py +++ b/about_code_tool/tests/test_genabout.py @@ -63,7 +63,9 @@ def test_get_mapping_list(self): gen = genabout.GenAbout() expected_list = {'about_file': 'directory/filename', 'version': 'confirmed version', - 'about_resource': 'file_name', 'name': 'component'} + 'about_resource': 'file_name', + 'name': 'component', + 'copyright': 'confirmed copyright'} output = gen.get_mapping_list() self.assertTrue(output == expected_list) @@ -295,11 +297,11 @@ def test_pre_generation_about_is_dir_exists_action_0(self): action_num = 0 input_list = [{'about_file': '/TESTCASE/', 'version': '0.8.1', 'about_resource': '.', 'name': 'ABOUT tool'}] - expected_output_list = [[join(TESTDATA_PATH, 'test_files_for_genabout/TESTCASE.ABOUT'), + expected_output_list = [[join(TESTDATA_PATH, 'test_files_for_genabout/TESTCASE', 'TESTCASE.ABOUT'), {'about_file': '/TESTCASE/', 'version': '0.8.1', 'about_resource': '.', 'name': 'ABOUT tool'}]] output_list = gen.pre_generation(gen_location, input_list, action_num, False) - self.assertTrue(expected_output_list == output_list, "This output_list should be empty.") + self.assertTrue(expected_output_list == output_list) self.assertFalse(gen.warnings, "No warnings should be returned.") self.assertFalse(gen.errors, "No errors should be returned.")