Read a obo file and yield '[Term]' entries.

    :param filepath: file path of the .obo file

    :yields: lists containing all lines from a obo '[Term]' entry. Lines are not
        processed and still contain the newline character.

def oboTermParser(filepath):
    """Read a obo file and yield '[Term]' entries.

    :param filepath: file path of the .obo file

    :yields: lists containing all lines from a obo '[Term]' entry. Lines are not
        processed and still contain the newline character.
    """
    with io.open(filepath) as openfile:
        lineIter = iter([i.rstrip() for i in openfile.readlines()])

    #Iterate through lines until the first obo "[Term]" is encountered
    try:
        line = next(lineIter)
        while line != '[Term]':
            line = next(lineIter)
        header = line #Remove
        entryLines = list()
    except StopIteration:
        errorText = 'File does not contain obo "[Term]" entries.'
        raise maspy.errors.FileFormatError(errorText)

    for line in lineIter:
        #Skip empty lines between entries
        if not line:
            continue
        if line == '[Term]':
            yield entryLines
            header = line #Remove
            entryLines = list()
        else:
            entryLines.append(line)

    #Yield last entry
    if entryLines:
        yield entryLines