Serializes the given value to YAML.

    :param value: the value to serialize
    :param pretty:
        whether or not to format the output in a more human-readable way; if
        not specified, defaults to ``False``
    :type pretty: bool
    :rtype: str

def to_yaml(value, pretty=False):
    """
    Serializes the given value to YAML.

    :param value: the value to serialize
    :param pretty:
        whether or not to format the output in a more human-readable way; if
        not specified, defaults to ``False``
    :type pretty: bool
    :rtype: str
    """

    if not yaml:
        raise NotImplementedError('No supported YAML library available')

    options = {
        'Dumper': BasicYamlDumper,
        'allow_unicode': True,
    }
    options['default_flow_style'] = not pretty

    return yaml.dump(value, **options).rstrip()