def _element_to_bson(key, value, check_keys, opts):
 if (not isinstance(key, string_type)):
  raise InvalidDocument(('documents must have only string keys, key was %r' % (key,)))
 if check_keys:
  if key.startswith('$'):
   raise InvalidDocument(("key %r must not start with '$'" % (key,)))
  if ('.' in key):
   raise InvalidDocument(("key %r must not contain '.'" % (key,)))
 name = _make_name(key)
 return _name_value_to_bson(name, value, check_keys, opts)

def _element_to_bson ( key , value , check_keys , opts ) : if ( not isinstance ( key , string_type ) ) : raise InvalidDocument ( ( 'documents must have only string keys, key was %r' % ( key , ) ) ) if check_keys : if key . startswith ( '$' ) : raise InvalidDocument ( ( "key %r must not start with '$'" % ( key , ) ) ) if ( '.' in key ) : raise InvalidDocument ( ( "key %r must not contain '.'" % ( key , ) ) ) name = _make_name ( key ) return _name_value_to_bson ( name , value , check_keys , opts )
encode a single key .