def _qual_arg(user_value,
              python_arg_name,
              gblock_arg_name,
              allowable):
    """
    Construct and sanity check a qualitative argument to
    send to gblocks.

    user_value: value to try to send to gblocks
    python_arg_name: name of python argument (for error string)
    gblock_arg_name: name of argument in gblocks
    allowable: dictionary of allowable values mapping python to
               whatever should be jammed into gblocks
    """

    if user_value in allowable.keys():
        return "-{}={}".format(gblock_arg_name,allowable[user_value])
    else:
        err = "\n\n{} '{}' not recognized\n".format(python_arg_name,
                                                user_value)
        err += "must be one of:\n"

        allowed = list(allowable)
        allowed.sort()
        for a in allowed:
            err += "    {}\n".format(a)

        raise ValueError(err)