<commit_before>import pymongo
import gridfs

from .datastore import DataStore


class MongoDBDataStore(pymongo.MongoClient, DataStore):
    db_name = 'librarypaste'

    @property
    def db(self):
        return self[self.db_name]

    @classmethod
    def from_uri(cls, uri):
        store = cls(uri)
        uri_p = pymongo.uri_parser.parse_uri(uri)
        if uri_p['database']:
            store.db_name = uri_p['database']
        return store

    def _store(self, uid, content, data=None):
        """Store the given dict of content at uid. Nothing returned."""
        doc = dict(uid=uid)
        if data:
            gfs = gridfs.GridFS(self.db)
            id = gfs.put(data, encoding='utf-8')
            doc.update(data_id=id)
        doc.update(content)
        self.db.pastes.save(doc, w=1)

    def _storeLog(self, nick, time, uid):
        """Adds the nick & uid to the log for a given time/order. No return."""
        query = dict(uid=uid)<commit_msg>Correct DeprecationWarning in Collection.save<commit_after>import pymongo
import gridfs

from .datastore import DataStore


class MongoDBDataStore(pymongo.MongoClient, DataStore):
    db_name = 'librarypaste'

    @property
    def db(self):
        return self[self.db_name]

    @classmethod
    def from_uri(cls, uri):
        store = cls(uri)
        uri_p = pymongo.uri_parser.parse_uri(uri)
        if uri_p['database']:
            store.db_name = uri_p['database']
        return store

    def _store(self, uid, content, data=None):
        """Store the given dict of content at uid. Nothing returned."""
        doc = dict(uid=uid)
        if data:
            gfs = gridfs.GridFS(self.db)
            id = gfs.put(data, encoding='utf-8')
            doc.update(data_id=id)
        doc.update(content)
        self.db.pastes.insert_one(doc)

    def _storeLog(self, nick, time, uid):
        """Adds the nick & uid to the log for a given time/order. No return."""
        query = dict(uid=uid)
{'fraction_non_alphanumeric': 0.11201216421692854, 'fraction_numerical': 0.0015205271160669033, 'mean_word_length': 2.41522491349481, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1044986', 'n_tokens_mistral': 646, 'n_tokens_neox': 629, 'n_words': 161}