<commit_before>
import bson
import pymongo
import datastore


__version__ = '1.2'
__author__ = '<NAME> <<EMAIL>>'


class Doc(object):
  '''Document key constants for datastore documents.'''
  _id = '_id'
  key = 'key'
  value = 'val'
  wrapped = '_wrapped'


class MongoDatastore(datastore.Datastore):
  '''Represents a Mongo database as a datastore.'''

  def __init__(self, mongoDatabase):
    self.database = mongoDatabase
    self._indexed = {}

  def _collectionNamed(self, name):
    '''Returns the `collection` named `name`.'''

    collection = self.database[name]

    # ensure there is an index, at least once per run.
    if name not in self._indexed:
      collection.create_index(Doc.key, unique=True)
      self._indexed[name] = True

    return collection

  @staticmethod
  def _collectionNameForKey(key):<commit_msg>cleaned up mongo.py imports and added __doc__<commit_after>
__version__ = '1.2'
__author__ = '<NAME> <<EMAIL>>'
__doc__ = '''
MongoDB (pymongo) datastore implementation.

Tested with:
MongoDB 1.8.2
pymongo 1.11+
'''


import pymongo
import datastore


class Doc(object):
  '''Document key constants for datastore documents.'''
  _id = '_id'
  key = 'key'
  value = 'val'
  wrapped = '_wrapped'


class MongoDatastore(datastore.Datastore):
  '''Represents a Mongo database as a datastore.'''

  def __init__(self, mongoDatabase):
    self.database = mongoDatabase
    self._indexed = {}

  def _collectionNamed(self, name):
    '''Returns the `collection` named `name`.'''

    collection = self.database[name]

    # ensure there is an index, at least once per run.
    if name not in self._indexed:
      collection.create_index(Doc.key, unique=True)
      self._indexed[name] = True

    return collection

  @staticmethod
  def _collectionNameForKey(key):
{'fraction_non_alphanumeric': 0.1171875, 'fraction_numerical': 0.005580357142857143, 'mean_word_length': 3.8328840970350404, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3913448', 'n_tokens_mistral': 607, 'n_tokens_neox': 583, 'n_words': 168}