
from __future__ import absolute_import
from __future__ import division


def to_str(value):
    if isinstance(value, str):
        return value
    elif isinstance(value, bytes):
        return value.decode('utf-8')
    else:
        raise ValueError(
            'Expected a textual value, given {} of type {}.'.format(
                value, type(value)))


def to_binary(value):
    if isinstance(value, bytes):
        return value
    else:
        return value.encode('utf-8')
