from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import ruamel.yaml as yaml
from spdx.writers.tagvalue import InvalidDocumentError
from spdx.writers.jsonyaml import Writer
import rdflib

def write_document(document, out, validate=True):

    if validate:
        messages = []
        messages = document.validate(messages)
        if messages:
            raise InvalidDocumentError(messages)

    writer = Writer(document)
    document_object = writer.create_document()

    yaml.round_trip_dump(document_object, out, indent=2, explicit_start=True)

Add YAML documents creating capability.
Add YAML documents creating capability.

Signed-off-by: Xavier Figueroa <2556c6f4facc1e5829d3394b9ce7316a84702c26@gmail.com>
