(output, output_formats, data, result, fn_name)
| 179 | |
| 180 | |
| 181 | def write_output(output, output_formats, data, result, fn_name): |
| 182 | written_filenames = [] |
| 183 | |
| 184 | if output is None: |
| 185 | # Output is disabled |
| 186 | return result |
| 187 | |
| 188 | if callable(output): |
| 189 | # Dynamic output handling |
| 190 | output(data, result) |
| 191 | else: |
| 192 | # Default format is JSON if not specified |
| 193 | output_formats = output_formats or ["JSON"] |
| 194 | |
| 195 | if output == "default": |
| 196 | default_filename = fn_name |
| 197 | else: |
| 198 | default_filename = output |
| 199 | |
| 200 | for fm in output_formats: |
| 201 | if fm == Formats.JSON: |
| 202 | filename = fix_json_filename(default_filename) |
| 203 | written_filenames.append(filename) |
| 204 | write_json(result, filename, False) |
| 205 | elif fm == Formats.CSV: |
| 206 | filename = fix_csv_filename(default_filename) |
| 207 | written_filenames.append(filename) |
| 208 | write_csv(result, filename, False) |
| 209 | elif fm == Formats.EXCEL: |
| 210 | filename = fix_excel_filename(default_filename) |
| 211 | written_filenames.append(filename) |
| 212 | write_excel(result, filename, False) |
| 213 | |
| 214 | print_filenames(written_filenames) |
| 215 | |
| 216 | |
| 217 | def clean_error_logs(error_logs_dir, sort_key): |
no test coverage detected