code: def mapping_get(uri, mapping):
      
      ln = localname(uri)
      # 1. try to match URI keys
      for k, v in mapping.items():
          if k == uri:
              return v
      # 2. try to match local names
      for k, v in mapping.items():
          if k == ln:
              return v
      # 3. try to match local names with * prefix
      # try to match longest first, so sort the mapping by key length
      l = list(mapping.items())
      l.sort(key=lambda i: len(i[0]), reverse=True)
      for k, v in l:
          if k[0] == '*' and ln.endswith(k[1:]):
              return v
      raise KeyError(uri)
docs: Look up the URI in the given mapping and return the result.
  
      Throws KeyError if no matching mapping was found.