def parse(f, encoding='utf-8'):
    """
    Parse the TDL file *f* and yield the interpreted contents.

    If *f* is a filename, the file is opened and closed when the
    generator has finished, otherwise *f* is an open file object and
    will not be closed when the generator has finished.

    Args:
        f (str, file): a filename or open file object
        encoding (str): the encoding of the file (default: `"utf-8"`;
            ignored if *f* is an open file)
    """
    if hasattr(f, 'read'):
        for event in _parse(f):
            yield event
    else:
        with io.open(f, encoding=encoding) as fh:
            for event in _parse(fh):
                yield event
def parse ( f , encoding = 'utf-8' ) : if hasattr ( f , 'read' ) : for event in _parse ( f ) : yield event else : with io . open ( f , encoding = encoding ) as fh : for event in _parse ( fh ) : yield event
Parse the TDL file *f* and yield the interpreted contents.

    If *f* is a filename, the file is opened and closed when the
    generator has finished, otherwise *f* is an open file object and
    will not be closed when the generator has finished.

    Args:
        f (str, file): a filename or open file object
        encoding (str): the encoding of the file (default: `"utf-8"`;
            ignored if *f* is an open file)