def query_tasks(session):
 if session.config['singletons']:
  for item in session.lib.items(session.query):
   (yield SingletonImportTask(None, item))
 else:
  for album in session.lib.albums(session.query):
   log.debug(u'yielding album {0}: {1} - {2}'.format(album.id, album.albumartist, album.album))
   items = list(album.items())
   for item in items:
    item.id = None
    item.album_id = None
   (yield ImportTask(None, [album.item_dir()], items))

def query_tasks ( session ) : if session . config [ 'singletons' ] : for item in session . lib . items ( session . query ) : ( yield SingletonImportTask ( None , item ) ) else : for album in session . lib . albums ( session . query ) : log . debug ( u'yielding album {0}: {1} - {2}' . format ( album . id , album . albumartist , album . album ) ) items = list ( album . items ( ) ) for item in items : item . id = None item . album_id = None ( yield ImportTask ( None , [ album . item_dir ( ) ] , items ) )
a generator that works as a drop-in-replacement for read_tasks .