Source code for pypenelopetools.penelope.input
"""
Definition of base input classes.
"""
# Standard library modules.
import abc
# Third party modules.
# Local modules.
from pypenelopetools.penelope.base import InputLineBase
# Globals and constants variables.
[docs]class PenelopeInputBase(InputLineBase):
"""
Base input class.
"""
[docs] def read(self, fileobj):
"""
Reads an input file (i.e. ``.in``).
Args:
fileobj (file object): File object opened with read access.
"""
for keyword in self.get_keywords():
keyword.read(fileobj)
[docs] def write(self, fileobj):
"""
Writes to an input file (i.e. ``.in``).
Args:
fileobj (file object): File object opened with write access.
"""
for keyword in self.get_keywords():
keyword.write(fileobj)
[docs] @abc.abstractmethod
def get_keywords(self):
"""
Returns:
list: Sorted list of all keywords in the input.
"""
return []