def _sub_fetch_file(url, md5sum=None):
    contents = ''
    try:
        fh = urlopen(url)
        contents = fh.read()
        if md5sum is not None:
            filehash =  hashlib.md5(contents).hexdigest()
            if md5sum and filehash != md5sum:
                raise DownloadFailed("md5sum didn't match for %s.  Expected %s got %s"%(url, md5sum, filehash))
    except URLError as ex:
        raise DownloadFailed(str(ex))

    return contents
Sub-routine of _fetch_file
dataset/ETHPy150Open ros-infrastructure/rosdep/src/rosdep2/platforms/source.py/_sub_fetch_file