def patch(original, patch):
    """
    Apply the patch to the given text.

    :param original: the original text to patch
    :param patch: the patch to apply
    :exception PatchFailedException: if unable to apply
    :return: the revised text
    """
    if isinstance(original, str):
        original = original.splitlines()
    return patch.apply_to(original)
