def diff_map(self, incolls):
        """Generate SQL to transform existing collations

        :param incolls: a YAML map defining the new collations
        :return: list of SQL statements

        Compares the existing collation definitions, as fetched from
        the catalogs, to the input map and generates SQL statements to
        create, drop or change the collations accordingly.
        """
        stmts = []
        # check input collations
        for cll in incolls:
            incoll = incolls[cll]
            # does it exist in the database?
            if cll in self:
                stmts.append(self[cll].diff_map(incoll))
            else:
                # check for possible RENAME
                if hasattr(incoll, 'oldname'):
                    oldname = incoll.oldname
                    try:
                        stmts.append(self[oldname].rename(incoll.name))
                        del self[oldname]
                    except __HOLE__ as exc:
                        exc.args = ("Previous name '%s' for collation '%s' "
                                    "not found" % (oldname, incoll.name), )
                        raise
                else:
                    # create new collation
                    stmts.append(incoll.create())
        # check database collations
        for (sch, cll) in self:
            # if missing, drop it
            if (sch, cll) not in incolls:
                stmts.append(self[(sch, cll)].drop())

        return stmts
dataset/ETHPy150Open perseas/Pyrseas/pyrseas/dbobject/collation.py/CollationDict.diff_map