from warnings import warn


def mergeReact(message, partial):
    """
    Returns (complete_message, partial).

    message must be a ReactMsg. partial is the previous partial
    (returned from last mergeReact invocation).
    """
    if message.get_type() == 0: # partial
        if partial is None:
            warn("Partial found but no partial in progress: ignoring")
        else:
            partial = partial.merge(message)
    else: # full
        if partial is not None:
            warn("Message start but partial in progress: hijacking")
        partial = message

    if partial is not None and partial.complete():
        return (partial.extract(), None)
    return (None, partial)