Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
Attempted to make a dict wrapper that makes keyerror clearer.
  • Loading branch information
MicahGale committed Oct 11, 2024
commit 5c9e642ed6517d4b850acf5cb3a7c376abf38814
15 changes: 15 additions & 0 deletions src/endf/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@
20040: 'Incident-alpha data'
}

class _DictWrapper(dict):

def __getitem__(self, key):
try:
super().__getitem__(key)
except KeyError as e:
if isinstance(key, tuple) and len(key) == 2:
key_text =f"MF={key[0]}, MT={key[1]}"
else:
key_text = str(key)
raise KeyError(f"The requested data: {key_text} are not present in this file.")

#try to make immutable
__setitem__ = None



class Material:
Expand Down