Get an instance of a map by name. Errors if the map doesn't exist.

def get(map_name):
  """Get an instance of a map by name. Errors if the map doesn't exist."""
  if isinstance(map_name, Map):
    return map_name

  # Get the list of maps. This isn't at module scope to avoid problems of maps
  # being defined after this module is imported.
  maps = get_maps()
  map_class = maps.get(map_name)
  if map_class:
    return map_class()
  raise NoMapException("Map doesn't exist: %s" % map_name)