def parse_compound_file(path, format):
context = FilePathContext(path)<EOL>format = resolve_format(format, context.filepath)<EOL>if format == '<STR_LIT>':<EOL><INDENT>logger.debug('<STR_LIT>'.format(<EOL>context.filepath))<EOL>with context.open('<STR_LIT:r>') as f:<EOL><INDENT>for compound in parse_compound_yaml_file(context, f):<EOL><INDENT>yield compound<EOL><DEDENT><DEDENT><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>logger.debug('<STR_LIT>'.format(<EOL>context.filepath))<EOL>with context.open('<STR_LIT:r>') as f:<EOL><INDENT>for compound in modelseed.parse_compound_file(f, context):<EOL><INDENT>yield compound<EOL><DEDENT><DEDENT><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>logger.debug('<STR_LIT>'.format(<EOL>context.filepath))<EOL>with context.open('<STR_LIT:r>') as f:<EOL><INDENT>for compound in parse_compound_table_file(context, f):<EOL><INDENT>yield compound<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise ParseError('<STR_LIT>'.format(<EOL>context.filepath))<EOL><DEDENT>
Open and parse reaction file based on file extension or given format

    Path can be given as a string or a context.