Iterate over entries in KEGG file.

def parse_kegg_entries(f, context=None):
    """Iterate over entries in KEGG file."""

    section_id = None
    entry_line = None
    properties = {}
    for lineno, line in enumerate(f):
        if line.strip() == '///':
            # End of entry
            mark = FileMark(context, entry_line, 0)
            yield KEGGEntry(properties, filemark=mark)
            properties = {}
            section_id = None
            entry_line = None
        else:
            if entry_line is None:
                entry_line = lineno

            # Look for beginning of section
            m = re.match(r'([A-Z_]+)\s+(.*)', line.rstrip())
            if m is not None:
                section_id = m.group(1).lower()
                properties[section_id] = [m.group(2)]
            elif section_id is not None:
                properties[section_id].append(line.strip())
            else:
                raise ParseError(
                    'Missing section identifier at line {}'.format(lineno))