# Path: molmod/io/common.py
# class FileFormatError(Exception):
#     """Is raised when unexpected data is encountered while reading a file"""
#     pass


from molmod.io.common import FileFormatError
        import copy
    def dump_children(self, f, indent=''):
        """Dump the children of the current section to a file-like object"""
        for child in self.__order:
            child.dump(f, indent+'  ')

    def dump(self, f, indent=''):
        """Dump this section and its children to a file-like object"""
        print(("%s&%s %s" % (indent, self.__name, self.section_parameters)).rstrip(), file=f)
        self.dump_children(f, indent)
        print("%s&END %s" % (indent, self.__name), file=f)

    def readline(self, f):
        """A helper method that only reads uncommented lines"""
        while True:
            line = f.readline()
            if len(line) == 0:
                raise EOFError
            line = line[:line.find('#')]
            line = line.strip()
            if len(line) > 0:
                return line

    def load_children(self, f):
        """Load the children of this section from a file-like object"""
        while True:
            line = self.readline(f)
            if line[0] == '&':
                if line[1:].startswith("END"):
                    check_name = line[4:].strip().upper()
                    if check_name != self.__name:

# Path: molmod/io/common.py
# class FileFormatError(Exception):
#     """Is raised when unexpected data is encountered while reading a file"""
#     pass


# Path: molmod/io/cp2k.py
from molmod.io.common import FileFormatError
        import copy

    def dump_children(self, f, indent=''):
        """Dump the children of the current section to a file-like object"""
        for child in self.__order:
            child.dump(f, indent+'  ')

    def dump(self, f, indent=''):
        """Dump this section and its children to a file-like object"""
        print(("%s&%s %s" % (indent, self.__name, self.section_parameters)).rstrip(), file=f)
        self.dump_children(f, indent)
        print("%s&END %s" % (indent, self.__name), file=f)

    def readline(self, f):
        """A helper method that only reads uncommented lines"""
        while True:
            line = f.readline()
            if len(line) == 0:
                raise EOFError
            line = line[:line.find('#')]
            line = line.strip()
            if len(line) > 0:
                return line

    def load_children(self, f):
        """Load the children of this section from a file-like object"""
        while True:
            line = self.readline(f)
            if line[0] == '&':
                if line[1:].startswith("END"):
                    check_name = line[4:].strip().upper()
                    if check_name != self.__name:

                        raise FileFormatError("CP2KSection end mismatch, pos=%s", f.tell())