def get_collections(db, collection=None, prefix=None, suffix=None):
if collection is not None:<EOL><INDENT>return [collection, ]<EOL><DEDENT>collections = db.collection_names(include_system_collections=False)<EOL>if prefix is not None:<EOL><INDENT>collections = [c for c in collections if c.startswith(prefix)]<EOL><DEDENT>if suffix is not None:<EOL><INDENT>collections = [c for c in collections if c.endswith(suffix)]<EOL><DEDENT>return sorted(collections)<EOL>
Returns a sorted list of collection names found in ``db``.

Arguments:

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

    collection (str): Name of a collection. If the collection is
        present in the MongoDB database, a single-element list will
        be returned with the collecion name. If not, an empty list
        will be returned. This option is primarly included to allow
        for quick checking to see if a collection name is present.
        Default is None, which results in this option being ignored.

    prefix (str): If supplied, only collections that begin with
        ``prefix`` will be returned.

    suffix (str): If supplied, only collections that end with
        ``suffix`` will be returned.

Returns:

    list: A sorted list of collection names.