diff --git a/vsg/__main__.py b/vsg/__main__.py index 28502817..4bcbcee9 100644 --- a/vsg/__main__.py +++ b/vsg/__main__.py @@ -68,7 +68,6 @@ def read_configuration_files(commandLineArguments): if commandLineArguments.configuration: dConfiguration = {} for sFileName in commandLineArguments.configuration: -# print(sFileName) tempConfiguration = open_configuration_file(sFileName, commandLineArguments) for sKey in tempConfiguration.keys(): @@ -76,16 +75,17 @@ def read_configuration_files(commandLineArguments): if not 'file_list' in dConfiguration: dConfiguration['file_list'] = [] for iIndex, sFilename in enumerate(tempConfiguration['file_list']): -# print(sFilename) -# print(glob.glob(expand_filename(sFilename))) - for sGlobbedFilename in glob.glob(expand_filename(sFilename)): -# print(sGlobbedFilename) try: -# print('Extending') + for sGlobbedFilename in glob.glob(expand_filename(sFilename)): dConfiguration['file_list'].append(sGlobbedFilename) - except: - dConfiguration['file_list'] = [sGlobbedFilename] -# print(dConfiguration) + except TypeError: + sKey = list(sFilename.keys())[0] + for sGlobbedFilename in glob.glob(expand_filename(sKey)): + dTemp = {} + dTemp[sGlobbedFilename] = {} + dTemp[sGlobbedFilename].update(tempConfiguration['file_list'][iIndex][sKey]) + dConfiguration['file_list'].append(dTemp) + elif sKey == 'rule': for sRule in tempConfiguration[sKey]: try: @@ -255,7 +255,6 @@ def main(): display_rule_configuration(commandLineArguments, configuration) for iIndex, sFileName in enumerate(commandLineArguments.filename): -# print(sFileName) oVhdlFile = vhdlFile.vhdlFile(read_vhdlfile(sFileName)) oVhdlFile.filename = sFileName oRules = rule_list.rule_list(oVhdlFile, commandLineArguments.local_rules) diff --git a/vsg/tests/vsg/read_configuration_files/__init__.py b/vsg/tests/vsg/read_configuration_files/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/vsg/tests/vsg/read_configuration_files/config_w_file_list_globbing_w_individual_rule_config.json b/vsg/tests/vsg/read_configuration_files/config_w_file_list_globbing_w_individual_rule_config.json new file mode 100644 index 00000000..9cbf741b --- /dev/null +++ b/vsg/tests/vsg/read_configuration_files/config_w_file_list_globbing_w_individual_rule_config.json @@ -0,0 +1,19 @@ +{ + "file_list" : [ + "vsg/tests/vsg/read_configuration_files/entity.vhd", + "vsg/tests/vsg/read_configuration_files/arch*.vhd":{ + "rule":{ + "rule_001":{ + "disable": true + } + } + }, + "vsg/tests/vsg/read_configuration_files/package.vhd":{ + "rule":{ + "rule_002":{ + "disable": false + } + } + } + ] +} diff --git a/vsg/tests/vsg/read_configuration_files/config_w_file_list_w_individual_rule_config.json b/vsg/tests/vsg/read_configuration_files/config_w_file_list_w_individual_rule_config.json new file mode 100644 index 00000000..a8964f0f --- /dev/null +++ b/vsg/tests/vsg/read_configuration_files/config_w_file_list_w_individual_rule_config.json @@ -0,0 +1,13 @@ +{ + "file_list" : [ + "vsg/tests/vsg/read_configuration_files/entity.vhd", + "vsg/tests/vsg/read_configuration_files/arch.vhd":{ + "rule":{ + "rule_001":{ + "disable":True + } + } + }, + "vsg/tests/vsg/read_configuration_files/package.vhd" + ] +} diff --git a/vsg/tests/vsg/read_configuration_files/test_read_configuration_files_function.py b/vsg/tests/vsg/read_configuration_files/test_read_configuration_files_function.py index ab547141..bf0561fa 100644 --- a/vsg/tests/vsg/read_configuration_files/test_read_configuration_files_function.py +++ b/vsg/tests/vsg/read_configuration_files/test_read_configuration_files_function.py @@ -39,7 +39,6 @@ class test_read_configuration_function(unittest.TestCase): def test_globbing_files(self): - self.maxDiff = None oCommandLineArgs = command_line_args(['vsg/tests/vsg/read_configuration_files/config_w_file_globbing.json']) dExpected = {} @@ -55,3 +54,51 @@ class test_read_configuration_function(unittest.TestCase): self.assertEqual(dActual, dExpected) + def test_file_list_with_individual_rule_config(self): + self.maxDiff = None + oCommandLineArgs = command_line_args(['vsg/tests/vsg/read_configuration_files/config_w_file_list_w_individual_rule_config.json']) + + dExpected = {} + dExpected['file_list'] = [] + dExpected['file_list'].append('vsg/tests/vsg/read_configuration_files/entity.vhd') + dFile = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule']['rule_001'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule']['rule_001']['disable'] = True + dExpected['file_list'].append(dFile) + dExpected['file_list'].append('vsg/tests/vsg/read_configuration_files/package.vhd') + + dActual = read_configuration_files(oCommandLineArgs) + + self.assertEqual(dActual, dExpected) + + def test_file_list_globbing_with_individual_rule_config(self): + self.maxDiff = None + oCommandLineArgs = command_line_args(['vsg/tests/vsg/read_configuration_files/config_w_file_list_globbing_w_individual_rule_config.json']) + + dExpected = {} + dExpected['file_list'] = [] + dExpected['file_list'].append('vsg/tests/vsg/read_configuration_files/entity.vhd') + dFile = {} + dFile['vsg/tests/vsg/read_configuration_files/arch_2.vhd'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch_2.vhd']['rule'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch_2.vhd']['rule']['rule_001'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch_2.vhd']['rule']['rule_001']['disable'] = True + dExpected['file_list'].append(dFile) + dFile = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule']['rule_001'] = {} + dFile['vsg/tests/vsg/read_configuration_files/arch.vhd']['rule']['rule_001']['disable'] = True + dExpected['file_list'].append(dFile) + dFile = {} + dFile['vsg/tests/vsg/read_configuration_files/package.vhd'] = {} + dFile['vsg/tests/vsg/read_configuration_files/package.vhd']['rule'] = {} + dFile['vsg/tests/vsg/read_configuration_files/package.vhd']['rule']['rule_002'] = {} + dFile['vsg/tests/vsg/read_configuration_files/package.vhd']['rule']['rule_002']['disable'] = False + dExpected['file_list'].append(dFile) + + dActual = read_configuration_files(oCommandLineArgs) + + self.assertEqual(dActual, dExpected)