def get_document(uri, params=None):
    """ Attempt to fetch user data from URL or file. And render, replacing
     parameters """

    if uri is None:
        raise ValueError("Document URI cannot be None")

    try:
        urlparse(uri)
        data = fetch_from_url(uri)
    except requests.exceptions.MissingSchema:
        # Not a url. possibly a file.
        uri = os.path.expanduser(uri)
        uri = os.path.abspath(uri)

        if os.path.isabs(uri):
            try:
                data = open(uri, 'r').read()
            except __HOLE__ as err:
                err_msg = "Failed to read from file: {}".format(err)
                raise DataError(err_msg)
        else:
            # Not url nor file.
            err_msg = "Unknown UserData source: {}".format(uri)
            raise DataError(err_msg)
    except requests.exceptions.ConnectionError as err:
        err_msg = "Failed to read from URL: {}".format(err)
        raise DataError(err_msg)

    data_tpl = Environment().from_string(data)
    return data_tpl.render(params)
dataset/ETHPy150Open onefinestay/gonzo/gonzo/helpers/document_loader.py/get_document