def lint_api(api_name, old, new, locations):
is_new_api = not old<EOL>api_location = locations['<STR_LIT>']<EOL>changelog = new.get('<STR_LIT>', {})<EOL>changelog_location = api_location<EOL>if locations['<STR_LIT>']:<EOL><INDENT>changelog_location = list(locations['<STR_LIT>'].values())[<NUM_LIT:0>]<EOL><DEDENT>if not new.get('<STR_LIT>'):<EOL><INDENT>msg_type = LintError if is_new_api else LintWarning<EOL>yield msg_type(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>api_name=api_name,<EOL>location=locations.get('<STR_LIT>', api_location)<EOL>)<EOL><DEDENT>introduced_at = new.get('<STR_LIT>')<EOL>if introduced_at is None:<EOL><INDENT>yield LintError(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>location=api_location,<EOL>)<EOL><DEDENT>if not is_new_api:<EOL><INDENT>old_introduced_at = old.get('<STR_LIT>')<EOL>if old_introduced_at is not None:<EOL><INDENT>if old_introduced_at != introduced_at:<EOL><INDENT>yield LintError(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>old_introduced_at,<EOL>introduced_at,<EOL>api_name=api_name,<EOL>location=api_location,<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if new['<STR_LIT:url>'] != old.get('<STR_LIT:url>', new['<STR_LIT:url>']):<EOL><INDENT>yield LintError(<EOL>'<STR_LIT:url>',<EOL>'<STR_LIT>',<EOL>old['<STR_LIT:url>'],<EOL>new['<STR_LIT:url>'],<EOL>api_name=api_name,<EOL>location=api_location,<EOL>)<EOL><DEDENT>for removed in set(old.get('<STR_LIT>', [])) - set(new['<STR_LIT>']):<EOL><INDENT>yield LintError(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>removed,<EOL>api_name=api_name,<EOL>location=api_location,<EOL>)<EOL><DEDENT>for schema in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>new_schema = new.get(schema)<EOL>if new_schema is None:<EOL><INDENT>continue<EOL><DEDENT>schema_location = locations[schema]<EOL>old_schema = old.get(schema, {})<EOL>for message in walk_schema(<EOL>schema, old_schema, new_schema, root=True, new_api=is_new_api):<EOL><INDENT>if isinstance(message, CheckChangelog):<EOL><INDENT>if message.revision not in changelog:<EOL><INDENT>yield LintFixit(<EOL>message.name,<EOL>'<STR_LIT>',<EOL>message.revision,<EOL>location=changelog_location,<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>message.location = schema_location<EOL>yield message<EOL><DEDENT><DEDENT><DEDENT>
Lint an acceptable api metadata.