import shutil


def binaries_check(app_configs, **kwargs):
    """
    Papermerge requires the existence of a few binaries, so we do some checks
    for those here.
    """

    msg = {
        "tesseract": "Without it, OCR of the documents is impossible",
        "pdfinfo": "Without it, Papermerge won't function properly",
        "pdftk": "Without it, Papermerge won't be able to cut/paste PDF pages"
    }
    error = "Papermerge can't find {}. {}."
    hint = "Either it's not in your PATH or it's not installed."

    check_messages = []
    for binary in msg.keys():
        if shutil.which(binary) is None:
            check_messages.append(
                Warning(
                    error.format(binary, msg[binary]),
                    hint
                )
            )

    return check_messages