import six
import warnings


def string_to_text(value, deprecate_msg):
    """
    Return input string coverted to text string.

    If input is text, it is returned as is.
    If input is binary, it is decoded using UTF-8 to text.
    """
    assert isinstance(value, (six.text_type, six.binary_type))
    if isinstance(value, six.binary_type):
        warnings.warn(deprecate_msg, DeprecationWarning)
        value = value.decode('utf-8')
    return value