def parse_reaction_file(path, default_compartment=None):
context = FilePathContext(path)<EOL>format = resolve_format(None, 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 reaction in parse_reaction_table_file(<EOL>context, f, default_compartment):<EOL><INDENT>yield reaction<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 reaction in parse_reaction_yaml_file(<EOL>context, f, default_compartment):<EOL><INDENT>yield reaction<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

    Path can be given as a string or a context.