def write_compartments(self, stream, compartments, adjacencies,<EOL>properties=None):
def convert(entry):<EOL><INDENT>return self.convert_compartment_entry(<EOL>entry, adjacencies.get(entry.id))<EOL><DEDENT>self._write_entries(stream, compartments, convert, properties)<EOL>
Write iterable of compartments as YAML object to stream.

        Args:
            stream: File-like object.
            compartments: Iterable of compartment entries.
            adjacencies: Dictionary mapping IDs to adjacent compartment IDs.
            properties: Set of compartment properties to output (or None to
                output all).