ihate: fix singletons (from #486, fix #411)

This commit is contained in:
Adrian Sampson 2014-02-08 12:11:32 -08:00
parent 67df43b9cf
commit ee713d153c
2 changed files with 20 additions and 9 deletions

View file

@ -26,6 +26,16 @@ __author__ = 'baobab@heresiarch.info'
__version__ = '2.0'
def summary(task):
"""Given an ImportTask, produce a short string identifying the
object.
"""
if task.is_album:
return u'{0} - {1}'.format(task.cur_artist, task.cur_album)
else:
return u'{0} - {1}'.format(task.item.artist, task.item.title)
class IHatePlugin(BeetsPlugin):
_log = logging.getLogger('beets')
@ -50,7 +60,7 @@ class IHatePlugin(BeetsPlugin):
query = get_query(query_string, Album)
else:
query = get_query(query_string, Item)
if any(query.match(item) for item in task.items):
if any(query.match(item) for item in task.imported_items()):
return True
return False
@ -63,12 +73,12 @@ class IHatePlugin(BeetsPlugin):
self._log.debug('[ihate] processing your hate')
if self.do_i_hate_this(task, skip_queries):
task.choice_flag = action.SKIP
self._log.info(u'[ihate] skipped: {0} - {1}'
.format(task.cur_artist, task.cur_album))
self._log.info(u'[ihate] skipped: {0}'
.format(summary(task)))
return
if self.do_i_hate_this(task, warn_queries):
self._log.info(u'[ihate] you maybe hate this: {0} - {1}'
.format(task.cur_artist, task.cur_album))
self._log.info(u'[ihate] you maybe hate this: {0}'
.format(summary(task)))
else:
self._log.debug('[ihate] nothing to do')
else:

View file

@ -28,10 +28,11 @@ Unrelated new stuff:
together in a single directory. Thanks to geigerzaehler.
* A new ``--config`` command-line option lets you specify an additional
configuration file. Thanks again to geigerzaehler.
* The :doc:`/plugins/ihate` was overhauled. Its configuration is now much
simpler---it uses beets queries instead of an ad-hoc per-field
configuration. This is *backwards-incompatible*---if you use this plugin,
you will need to update your configuration. Thanks to BrainDamage.
* :doc:`/plugins/ihate`: The plugin's configuration interface was overhauled.
Its configuration is now much simpler---it uses beets queries instead of an
ad-hoc per-field configuration. This is *backwards-incompatible*---if you
use this plugin, you will need to update your configuration. Thanks to
BrainDamage.
Other little fixes: