|
18 | 18 |
|
19 | 19 | from . import available_checks |
20 | 20 | from .inspector_tools import ( |
| 21 | + get_report_header, |
21 | 22 | organize_messages, |
22 | 23 | format_organized_results_output, |
23 | 24 | print_to_console, |
@@ -201,8 +202,12 @@ def inspect_all_cli( |
201 | 202 | ) |
202 | 203 | ) |
203 | 204 | if json_file_path is not None: |
| 205 | + if Path(json_file_path).exists() and not overwrite: |
| 206 | + raise FileExistsError(f"The file {json_file_path} already exists! Specify the '-o' flag to overwrite.") |
204 | 207 | with open(file=json_file_path, mode="w") as fp: |
205 | | - json.dump(obj=messages, fp=fp, cls=InspectorOutputJSONEncoder) |
| 208 | + json_report = dict(header=get_report_header(), messages=messages) |
| 209 | + json.dump(obj=json_report, fp=fp, cls=InspectorOutputJSONEncoder) |
| 210 | + print(f"{os.linesep*2}Report saved to {str(Path(json_file_path).absolute())}!{os.linesep}") |
206 | 211 | if len(messages): |
207 | 212 | organized_results = organize_messages(messages=messages, levels=["file_path", "importance"]) |
208 | 213 | formatted_results = format_organized_results_output(organized_results=organized_results) |
@@ -342,6 +347,7 @@ def inspect_nwb( |
342 | 347 | ) |
343 | 348 | nwbfile_path = str(nwbfile_path) |
344 | 349 | filterwarnings(action="ignore", message="No cached namespaces found in .*") |
| 350 | + filterwarnings(action="ignore", message="Ignoring cached namespace .*") |
345 | 351 | with pynwb.NWBHDF5IO(path=nwbfile_path, mode="r", load_namespaces=True, driver=driver) as io: |
346 | 352 | if skip_validate: |
347 | 353 | validation_errors = pynwb.validate(io=io) |
|
0 commit comments