def __pack_message(operation, data):
    """Takes message data and adds a message header based on the operation.

    Returns the resultant message string.
    """
    rid = _randint()
    message = _pack_header(16 + len(data), rid, 0, operation)
    return rid, message + data
Takes message data and adds a message header based on the operation.

    Returns the resultant message string.
    
stackoverflow/venv/lib/python3.6/site-packages/pymongo/message.py