def _buildMessageFormat(vin=None, rin=None, msg=None):
    """Builds a deprecation warning message from the arguments.

    :arg vin: Optional version - the warning message will mention that the
              function is deprecated from this version.

    :arg rin: Optional version - the warning message will mention that the
              function will be removed in this version.

    :arg msg: Optional message to use in the warning.

    :returns: A format string which needs to be formatted with a ``{name}``.
    """
    if vin is not None and rin is not None:
        msgfmt = (
            '{{name}} is deprecated from version {vin} and will be removed in {rin}.'
            .format(vin=vin, rin=rin))
    elif vin is not None:
        msgfmt = '{{name}} is deprecated from version {vin}.'.format(vin=vin)
    elif rin is not None:
        msgfmt = '{{name}} is deprecated and will be removed in {rin}.'.format(
            rin=rin)
    else:
        msgfmt = '{{name}} is deprecated.'
    if msg is not None:
        msgfmt = msgfmt + ' ' + msg
    return msgfmt
