check_mandatory_keys(data_dict: dict, mandatory_keys: list) None[source]#

Check all mandatory argument in a dictionary. Raise an exception if a mandatory argument is missing.

Note: nested keys do not work here !

>>> dct = {"A": "T", "R": 3}
>>> check_mandatory_keys(dct, ["A", "R"])  # Returns nothing, is OK
>>> check_mandatory_keys(dct, ["C"])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 167, in check_mandatory_keys
ValueError: Missing mandatory key 'C' among {'A': 'T', 'R': 3}
  • data_dict (dict) – Data dictionary to be checked

  • mandatory_keys (list[str]) – List of mandatory keys