Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions neutronics_material_maker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import warnings
from json.decoder import JSONDecodeError
from pathlib import Path
from typing import Optional

Expand Down Expand Up @@ -370,10 +371,13 @@ def AddMaterialFromFile(filename: str, verbose: Optional[bool] = True) -> None:
if verbose:
print("Added materials to library from", filename)
with open(filename, "r") as f:
new_data = json.load(f)
if verbose:
print('Added material', list(new_data.keys()))
material_dict.update(new_data)
try:
new_data = json.load(f)
if verbose:
print('Added material', list(new_data.keys()))
material_dict.update(new_data)
except JSONDecodeError:
print('JSONDecodeError, file not read in', filename)


def AvailableMaterials() -> dict:
Expand Down