Convert OPTIMADE entry to desired format. Parameters: format (str): Type or format to which the entry should be converted. Raises: AttributeError: If `format` can not be found in `_type_converters` or `_common_converters`. Returns: The c
(self, format: str)
| 77 | return self._entry |
| 78 | |
| 79 | def convert(self, format: str) -> Any: |
| 80 | """Convert OPTIMADE entry to desired format. |
| 81 | |
| 82 | Parameters: |
| 83 | format (str): Type or format to which the entry should be converted. |
| 84 | |
| 85 | Raises: |
| 86 | AttributeError: If `format` can not be found in `_type_converters` or `_common_converters`. |
| 87 | |
| 88 | Returns: |
| 89 | The converted entry according to the desired format or type. |
| 90 | |
| 91 | """ |
| 92 | if ( |
| 93 | format not in self._type_converters |
| 94 | and format not in self._common_converters |
| 95 | ): |
| 96 | raise AttributeError( |
| 97 | f"Non-valid entry type to convert to: {format}\nValid entry types: " |
| 98 | f"{tuple(self._type_converters.keys()) + tuple(self._common_converters.keys())}" |
| 99 | ) |
| 100 | |
| 101 | if self._converted.get(format, None) is None: |
| 102 | if format in self._type_converters: |
| 103 | self._converted[format] = self._type_converters[format](self.entry) |
| 104 | else: |
| 105 | self._converted[format] = self._common_converters[format]() |
| 106 | |
| 107 | return self._converted[format] |
| 108 | |
| 109 | @classmethod |
| 110 | def ingest_from(cls, data: Any, format: str | None = None) -> Any: |