def mapping_get(uri, mapping):
ln = localname(uri)<EOL>for k, v in mapping.items():<EOL><INDENT>if k == uri:<EOL><INDENT>return v<EOL><DEDENT><DEDENT>for k, v in mapping.items():<EOL><INDENT>if k == ln:<EOL><INDENT>return v<EOL><DEDENT><DEDENT>l = list(mapping.items())<EOL>l.sort(key=lambda i: len(i[<NUM_LIT:0>]), reverse=True)<EOL>for k, v in l:<EOL><INDENT>if k[<NUM_LIT:0>] == '<STR_LIT:*>' and ln.endswith(k[<NUM_LIT:1>:]):<EOL><INDENT>return v<EOL><DEDENT><DEDENT>raise KeyError(uri)<EOL>
Look up the URI in the given mapping and return the result.

    Throws KeyError if no matching mapping was found.