aiida_vasp.parsers.content_parsers.win#
The .win parser interface.
Module Contents#
Classes#
Common codebase for all parser utilities. |
|
Parses wannier90 input. |
API#
- class aiida_vasp.parsers.content_parsers.win.BaseKeyValueParser[source]#
Common codebase for all parser utilities.
- empty_line = 'compile(...)'#
- class aiida_vasp.parsers.content_parsers.win.KeyValueParser[source]#
Bases:
aiida_vasp.parsers.content_parsers.win.BaseKeyValueParserThis baseclass has some utility functions for parsing files that are (mostly) in a key = value format. This class does not integrate with the VaspParser class currently. A simple example, which tries to convert values to python objects on a best effort basis. Usage:
import re from aiida_vasp.parsers.file_parsers.parser import KeyValueParser ParamParser(KeyValueParser): def __init__(self, file_path): self._file_path = py.path.local(file_path) super().__init__() self.result = {} def convert_or_not(self, value): for converter in self.get_converter_iter(): converted = self.try_convert(value, converter) if converted and 'value' in converted: return converted['value'] return value def parse_file(self): assignments = re.findall(self.assignment, self._file_path.read()) return {key: self.convert_or_not(value)}
- Parses files like::
StrParam = value_1 FloatParam = 1.0 BoolParam = True
- assignment = 'compile(...)'#
- bool_true = 'compile(...)'#
- bool_false = 'compile(...)'#
- comment = True#
- classmethod retval(*args, **kwargs)[source]#
Normalize return values from value conversion functions.
- classmethod int_unit(string_)[source]#
Convert a string into a python value, associated unit and optional comment.