def ast_from_file(self, filepath, modname=None, fallback=True, source=False):
try:<EOL><INDENT>filepath = modutils.get_source_file(filepath, include_no_ext=True)<EOL>source = True<EOL><DEDENT>except modutils.NoSourceFile:<EOL><INDENT>pass<EOL><DEDENT>if modname is None:<EOL><INDENT>try:<EOL><INDENT>modname = "<STR_LIT:.>".join(modutils.modpath_from_file(filepath))<EOL><DEDENT>except ImportError:<EOL><INDENT>modname = filepath<EOL><DEDENT><DEDENT>if (<EOL>modname in self.astroid_cache<EOL>and self.astroid_cache[modname].file == filepath<EOL>):<EOL><INDENT>return self.astroid_cache[modname]<EOL><DEDENT>if source:<EOL><INDENT>from astroid.builder import AstroidBuilder<EOL>return AstroidBuilder(self).file_build(filepath, modname)<EOL><DEDENT>if fallback and modname:<EOL><INDENT>return self.ast_from_module_name(modname)<EOL><DEDENT>raise exceptions.AstroidBuildingError(<EOL>"<STR_LIT>", path=filepath<EOL>)<EOL>
given a module name, return the astroid object