Function to generate the Overview Table from the ini files that define the features for each driver. The default features for the table and their order is defined by the 'default.ini' file.
(output_filename, table_id, section, table_name, title)
| 115 | |
| 116 | |
| 117 | def generate_overview_table(output_filename, table_id, section, table_name, title): |
| 118 | """ |
| 119 | Function to generate the Overview Table from the ini files that define |
| 120 | the features for each driver. |
| 121 | |
| 122 | The default features for the table and their order is defined by the |
| 123 | 'default.ini' file. |
| 124 | |
| 125 | """ |
| 126 | # Default warning string. |
| 127 | warning = 'Warning generate_overview_table()' |
| 128 | |
| 129 | # Get the default features and order from the 'default.ini' file. |
| 130 | ini_path = path_join(dirname(output_filename), 'features') |
| 131 | config = configparser.ConfigParser() |
| 132 | config.optionxform = str |
| 133 | config.read(path_join(ini_path, 'default.ini')) |
| 134 | default_features = config.items(section) |
| 135 | |
| 136 | # Create a dict of the valid features to validate the other ini files. |
| 137 | valid_features = {} |
| 138 | max_feature_length = 0 |
| 139 | for feature in default_features: |
| 140 | key = feature[0] |
| 141 | valid_features[key] = ' ' |
| 142 | max_feature_length = max(max_feature_length, len(key)) |
| 143 | |
| 144 | # Get a list of driver ini files, excluding 'default.ini'. |
| 145 | ini_files = [basename(file) for file in listdir(ini_path) |
| 146 | if file.endswith('.ini') and file != 'default.ini'] |
| 147 | ini_files.sort() |
| 148 | |
| 149 | # Build up a list of the table header names from the ini filenames. |
| 150 | pmd_names = [] |
| 151 | for ini_filename in ini_files: |
| 152 | name = ini_filename[:-4] |
| 153 | name = name.replace('_vf', 'vf') |
| 154 | pmd_names.append(name) |
| 155 | if not pmd_names: |
| 156 | # Add an empty column if table is empty (required by RST syntax) |
| 157 | pmd_names.append(' ') |
| 158 | |
| 159 | # Pad the table header names. |
| 160 | max_header_len = len(max(pmd_names, key=len)) |
| 161 | header_names = [] |
| 162 | for name in pmd_names: |
| 163 | if '_vec' in name: |
| 164 | pmd, vec = name.split('_') |
| 165 | name = '{0:{fill}{align}{width}}vec'.format(pmd, |
| 166 | fill='.', align='<', width=max_header_len-3) |
| 167 | else: |
| 168 | name = '{0:{fill}{align}{width}}'.format(name, |
| 169 | fill=' ', align='<', width=max_header_len) |
| 170 | header_names.append(name) |
| 171 | |
| 172 | # Create a dict of the defined features for each driver from the ini files. |
| 173 | ini_data = {} |
| 174 | for ini_filename in ini_files: |
no test coverage detected