aiida_vasp.parsers.content_parsers.base#
Base classes for the VASP content parsers.
Contains the base classes for the VASP content parsers.
Module Contents#
Classes#
Base class for all the content parsers which parse (read and write) VASP files. |
API#
- class aiida_vasp.parsers.content_parsers.base.BaseFileParser(*, handler: TextIO | BinaryIO | None = None, data: aiida.orm.Data | None = None, settings: dict[str, Any] | None = None, options: dict[str, Any] | None = None, raise_errors: bool = False)[source]#
Base class for all the content parsers which parse (read and write) VASP files.
This class provides the interface for parsing and writing VASP files using parsevasp. It ensures integration with the AiiDA parsing framework and preparation before submission. Specific content parser interfaces should inherit from this class.
There are two main usage patterns:
Parsing from file: Initialize with
handler(a file-like object), then fetch quantities usingget_quantity()with the appropriate key. The valid keys are defined in thePARSABLE_QUANTITIESclass parameter of each subclass.Writing from data: Initialize with
data(an AiiDA data node), then useget_quantity()to retrieve the same node, or usewrite()to write the content to a file.
- Parameters:
handler (file-like object, optional) – File-like object containing content to be parsed. Used when parsing completed calculations.
data (object, optional) – AiiDA data node. Used when writing VASP input files.
settings (dict, optional) – Parser settings, e.g. which quantities to compose into nodes.
options (dict, optional) – Parser options, e.g. extra options for content parsers such as selective dynamics for POSCAR.
Initialization
- get_all_quantities() tuple[dict[str, Any], dict[str, Any]][source]#
Fetch all quantities that can be parsed.
- Returns:
Tuple of (parsed, errored) dictionaries.
- Return type:
- property parsable_quantities: list[str]#
Fetch the quantities that this content parser can provide.
- Returns:
List of parsable quantity keys.
- Return type:
- _set_settings(settings: dict[str, Any] | None) None[source]#
Set the settings to be used for the content parser.
- Parameters:
settings (None or dict) – The settings to be used for the content parser. Can be None if no settings is supplied to init. Defaults are then set.
- get_quantity(quantity_key: str) Any[source]#
Fetch the required quantity from the content parser.
Either fetch it from an existing AiiDA data structure, a parsed content dictionary if that exists, otherwise parse this specific quantity using the loaded instance, which is now a specific content parser.
- write(path: str) None[source]#
Write VASP content to file using the loaded content parser.
- Parameters:
path (str) – Path to write the file to.
- abstract _init_from_handler(handler: TextIO | BinaryIO) None[source]#
Initialize using a file-like object.
Should be overridden in specific content parsers under
content_parsersif it will accept parsable content.- Parameters:
handler (object) – File-like object that provides the necessary content to be parsed.
- abstract _init_from_data(data: aiida.orm.Data) None[source]#
Initialize using an AiiDA data structure.
Should be overridden in specific content parsers under
content_parsersif it will accept an AiiDA data structure. It should also check that the right structure is supplied.- Parameters:
data (object) – A valid AiiDA data structure object.
- abstract _content_data_to_content_parser() Any[source]#
Convert an AiiDA data structure to a content parser instance relevant for that data structure. E.g.
Poscarfromparsevaspfor an AiiDAStructureData.Should be overridden in specific content parsers under
content_parsersif it will accept an AiiDA data structure. It should also check that the right structure is supplied.- Returns:
Instance of a content parser from
parsevasp, e.g.Poscar.- Return type: