| 14 | namespace materialdft { |
| 15 | |
| 16 | py::dict require_dict(const py::dict& parent, const char* key, const std::string& where) { |
| 17 | if (!parent.contains(key)) { |
| 18 | throw std::invalid_argument(where + "." + key + " is required"); |
| 19 | } |
| 20 | if (!py::isinstance<py::dict>(parent[key])) { |
| 21 | throw std::invalid_argument(where + "." + key + " must be an object"); |
| 22 | } |
| 23 | return py::cast<py::dict>(parent[key]); |
| 24 | } |
| 25 | |
| 26 | py::list require_list(const py::dict& parent, const char* key, const std::string& where) { |
| 27 | if (!parent.contains(key)) { |
no outgoing calls
no test coverage detected