def main(argv=sys.argv[1:]):
    parser = ArgumentParser(description='Dowloads URI to file dest. If md5sum is given, checks md5sum. If file existed and mismatch, downloads and checks again')
    parser.add_argument('uri')
    parser.add_argument('dest')
    parser.add_argument('md5sum', nargs='?')
    parser.add_argument('--ignore-error', action='store_true', help='Ignore download errors')
    args = parser.parse_args(argv)

    uri = args.uri
    if '://' not in uri:
        uri = 'file://' + uri

    fresh = False
    if not os.path.exists(args.dest):
        try:
            download_md5(uri, args.dest)
        except Exception:
            if args.ignore_error:
                return 0
            raise
        fresh = True

    if args.md5sum:
        result, hexdigest = checkmd5(args.dest, args.md5sum)
        if result is False and fresh is False:
            print('WARNING: md5sum mismatch (%s != %s); re-downloading file %s' % (hexdigest, args.md5sum, args.dest))
            os.remove(args.dest)
            try:
                download_md5(uri, args.dest)
            except Exception:
                if args.ignore_error:
                    return 0
                raise
            result, hexdigest = checkmd5(args.dest, args.md5sum)
        if result is False:
            return 'ERROR: md5sum mismatch (%s != %s) on %s; aborting' % (hexdigest, args.md5sum, args.dest)

    return 0
Dowloads URI to file dest and checks md5 if given.
dataset/ETHPy150Open ros/catkin/cmake/test/download_checkmd5.py/main