'Dump a list of artifacts into a yaml string.'

def DumpArtifactsToYaml(self, sort_by_os=True):

    artifact_list = self.GetArtifacts()
    if sort_by_os:
        yaml_list = []
        done_set = set()
        for os_name in Artifact.SUPPORTED_OS_LIST:
            done_set = set((a for a in artifact_list if (a.supported_os == [os_name])))
            done_set = sorted(done_set, key=(lambda x: x.name))
            yaml_list.extend((x.ToYaml() for x in done_set if x.provides))
            yaml_list.extend((x.ToYaml() for x in done_set if (not x.provides)))
            artifact_list = artifact_list.difference(done_set)
        yaml_list.extend((x.ToYaml() for x in artifact_list))
    else:
        yaml_list = [x.ToYaml() for x in artifact_list]
    return '---\n\n'.join(yaml_list)
