def create_collection(request, bucket_id):
    # Do nothing if current request does not involve a collection.
    subpath = request.matchdict.get('subpath')
    if not (subpath and subpath.startswith('collections/')):
        return

    collection_id = subpath.split('/')[1]
    collection_uri = '/buckets/%s/collections/%s' % (bucket_id, collection_id)

    # Do not intent to create multiple times per request (e.g. in batch).
    already_created = request.bound_data.setdefault('collections', {})
    if already_created in collection_uri:
        return

    # Do nothing if current request will already create the collection.
    collection_put = (request.method.lower() == 'put' and
                      request.path.endswith(collection_id))
    if collection_put:
        return

    backup_matchdict = request.matchdict
    request.matchdict = dict(bucket_id=bucket_id,
                             id=collection_id,
                             **request.matchdict)
    collection = resource_create_object(request=request,
                                        resource_cls=Collection,
                                        uri=collection_uri,
                                        resource_name='collection',
                                        obj_id=collection_id)
    already_created[collection_uri] = collection
    request.matchdict = backup_matchdict
dataset/ETHPy150Open Kinto/kinto/kinto/plugins/default_bucket/__init__.py/create_collection/swapped operands of `in`