def resource_for_link(link, includes, resources=None, locale=None):
if resources is not None:<EOL><INDENT>cache_key = "<STR_LIT>".format(<EOL>link['<STR_LIT>']['<STR_LIT>'],<EOL>link['<STR_LIT>']['<STR_LIT:id>'],<EOL>locale<EOL>)<EOL>if cache_key in resources:<EOL><INDENT>return resources[cache_key]<EOL><DEDENT><DEDENT>for i in includes:<EOL><INDENT>if (i['<STR_LIT>']['<STR_LIT:id>'] == link['<STR_LIT>']['<STR_LIT:id>'] and<EOL>i['<STR_LIT>']['<STR_LIT:type>'] == link['<STR_LIT>']['<STR_LIT>']):<EOL><INDENT>return i<EOL><DEDENT><DEDENT>return None<EOL>
Returns the resource that matches the link