'Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the corresponding archive entries can be found. The
modifier is free to change the contents of the files pointed to, add
new entries and remove entries, before returning. This method will
extract the entire contents of the wheel to a temporary location, call
the modifier, and then use the passed (and possibly updated)
dictionary to write a new wheel. If ``dest_dir`` is specified, the new
wheel is written there -- otherwise, the original wheel is overwritten.
The modifier should return True if it updated the wheel, else False.
This method returns the same value the modifier returns.'

def update(self, modifier, dest_dir=None, **kwargs):

    def get_version(path_map, info_dir):
        version = path = None
        key = (u'%s/%s' % (info_dir, METADATA_FILENAME))
        if (key not in path_map):
            key = (u'%s/PKG-INFO' % info_dir)
        if (key in path_map):
            path = path_map[key]
            version = Metadata(path=path).version
        return (version, path)
    def update_version(version, path):
        updated = None
        try:
            v = NormalizedVersion(version)
            i = version.find(u'-')
            if (i < 0):
                updated = (u'%s+1' % version)
            else:
                parts = [int(s) for s in version[(i + 1):].split(u'.')]
                parts[(-1)] += 1
                updated = (u'%s+%s' % (version[:i], u'.'.join((str(i) for i in parts))))
        except UnsupportedVersionError:
            logger.debug(u'Cannot    update    non-compliant    (PEP-440)    version    %r', version)
        if updated:
            md = Metadata(path=path)
            md.version = updated
            legacy = (not path.endswith(METADATA_FILENAME))
            md.write(path=path, legacy=legacy)
            logger.debug(u'Version    updated    from    %r    to    %r', version, updated)
    pathname = os.path.join(self.dirname, self.filename)
    name_ver = (u'%s-%s' % (self.name, self.version))
    info_dir = (u'%s.dist-info' % name_ver)
    record_name = posixpath.join(info_dir, u'RECORD')
    with tempdir() as workdir:
        with ZipFile(pathname, u'r') as zf:
            path_map = {}
            for zinfo in zf.infolist():
                arcname = zinfo.filename
                if isinstance(arcname, text_type):
                    u_arcname = arcname
                else:
                    u_arcname = arcname.decode(u'utf-8')
                if (u_arcname == record_name):
                    continue
                if (u'..' in u_arcname):
                    raise DistlibException((u'invalid    entry    in    wheel:    %r' % u_arcname))
                zf.extract(zinfo, workdir)
                path = os.path.join(workdir, convert_path(u_arcname))
                path_map[u_arcname] = path
        (original_version, _) = get_version(path_map, info_dir)
        modified = modifier(path_map, **kwargs)
        if modified:
            (current_version, path) = get_version(path_map, info_dir)
            if (current_version and (current_version == original_version)):
                update_version(current_version, path)
            if (dest_dir is None):
                (fd, newpath) = tempfile.mkstemp(suffix=u'.whl', prefix=u'wheel-update-', dir=workdir)
                os.close(fd)
            else:
                if (not os.path.isdir(dest_dir)):
                    raise DistlibException((u'Not    a    directory:    %r' % dest_dir))
                newpath = os.path.join(dest_dir, self.filename)
            archive_paths = list(path_map.items())
            distinfo = os.path.join(workdir, info_dir)
            info = (distinfo, info_dir)
            self.write_records(info, workdir, archive_paths)
            self.build_zip(newpath, archive_paths)
            if (dest_dir is None):
                shutil.copyfile(newpath, pathname)
    return modified
