def rename_collection(db, collection, new_name):
if hasattr(new_name, '<STR_LIT>'):<EOL><INDENT>_new = new_name(collection)<EOL>if _new == '<STR_LIT>':<EOL><INDENT>return<EOL><DEDENT><DEDENT>else:<EOL><INDENT>_new = new_name<EOL><DEDENT>c = db[collection]<EOL>c.rename(_new)<EOL>
Renames a MongoDB collection.

Arguments:

    db (Database): A pymongo Database object. Can be obtained
        with ``get_db``.

    collection (str): Name of the collection to be renamed.

    new_name (str, func): ``new_name`` can be one of two things::

        1. The new collection name, as a string.
        2. A function which, when passed the current collection name,
            returns the new collection name. If the function
            returns an empty string, the collection will not be
            renamed.