Convert compartment entry to YAML dict.

        Args:
            compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
            adjacencies: Sequence of IDs or a single ID of adjacent
                compartments (or None).

def convert_compartment_entry(self, compartment, adjacencies):
        """Convert compartment entry to YAML dict.

        Args:
            compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
            adjacencies: Sequence of IDs or a single ID of adjacent
                compartments (or None).
        """
        d = OrderedDict()
        d['id'] = compartment.id
        if adjacencies is not None:
            d['adjacent_to'] = adjacencies

        order = {key: i for i, key in enumerate(['name'])}
        prop_keys = set(compartment.properties)
        for prop in sorted(prop_keys,
                           key=lambda x: (order.get(x, 1000), x)):
            if compartment.properties[prop] is not None:
                d[prop] = compartment.properties[prop]

        return d