Skip to content

Commit

Permalink
ENHANCEMENT : if JSON file have bad syntax, print CRITICAL message
Browse files Browse the repository at this point in the history
i would rather the runtime to not stop when there is one bad file, so i just remove the file...
  • Loading branch information
benoitberanger committed Jul 18, 2022
1 parent f57b75c commit 461878b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion niix2bids/utils.py
Expand Up @@ -190,8 +190,18 @@ def create_volume_list(file_list_nii: List[str]) -> List[Volume]:
@logit('Read all .json files. This step might take time, it involves reading lots of files', logging.INFO)
def read_all_json(volume_list: List[Volume]) -> None:

log = get_logger()

to_pop = []
for volume in volume_list:
volume.load_json()
try:
volume.load_json()
except json.JSONDecodeError:
log.critical(f"json have bad syntax : {volume.json.path}")
to_pop.append(volume)

# remove the Volume object for the instance list, so it will be "forgotten"
[Volume.instances.remove(elem) for elem in to_pop]


########################################################################################################################
Expand Down

0 comments on commit 461878b

Please sign in to comment.