def adapt(msg, to_version=protocol_version_info[0]):
    """Adapt a single message to a target version

    Parameters
    ----------

    msg : dict
        A Jupyter message.
    to_version : int, optional
        The target major version.
        If unspecified, adapt to the current version.

    Returns
    -------

    msg : dict
        A Jupyter message appropriate in the new version.
    """
    header = msg['header']
    if 'date' not in header:
        header['date'] = datetime.now().isoformat()
    if 'version' in header:
        from_version = int(header['version'].split('.')[0])
    else:
        # assume last version before adding the key to the header
        from_version = 4
    adapter = adapters.get((from_version, to_version), None)
    if adapter is None:
        return msg
    return adapter(msg)


# one adapter per major version from,to
dataset/ETHPy150Open jupyter/jupyter_client/jupyter_client/adapter.py/adapt/original