def find_engine(filepath=None, name=None):
if name is None:<EOL><INDENT>engines = anytemplate.engine.find_by_filename(filepath)<EOL>if not engines:<EOL><INDENT>raise TemplateEngineNotFound("<STR_LIT>" % str(filepath))<EOL><DEDENT>return engines[<NUM_LIT:0>]  <EOL><DEDENT>else:<EOL><INDENT>engine = anytemplate.engine.find_by_name(name)<EOL>if engine is None:<EOL><INDENT>raise TemplateEngineNotFound("<STR_LIT>" % name)<EOL><DEDENT>return engine<EOL><DEDENT>
:param filepath: Template file path
:param name: Specify the name of template engine to use explicitly or
    None; it will be selected automatically anyhow.

:return: Template engine class found