def decode_file_iter(file_obj, codec_options=DEFAULT_CODEC_OPTIONS):
 while True:
  size_data = file_obj.read(4)
  if (len(size_data) == 0):
   break
  elif (len(size_data) != 4):
   raise InvalidBSON('cut off in middle of objsize')
  obj_size = (_UNPACK_INT(size_data)[0] - 4)
  elements = (size_data + file_obj.read(obj_size))
  (yield _bson_to_dict(elements, codec_options))

def decode_file_iter ( file_obj , codec_options = DEFAULT_CODEC_OPTIONS ) : while True : size_data = file_obj . read ( 4 ) if ( len ( size_data ) == 0 ) : break elif ( len ( size_data ) != 4 ) : raise InvalidBSON ( 'cut off in middle of objsize' ) obj_size = ( _UNPACK_INT ( size_data ) [ 0 ] - 4 ) elements = ( size_data + file_obj . read ( obj_size ) ) ( yield _bson_to_dict ( elements , codec_options ) )
decode bson data from a file to multiple documents as a generator .