From e80dce6930c5ca2a75005fa434c0352523508ef3 Mon Sep 17 00:00:00 2001 From: Philippe Mongeau Date: Sun, 21 Oct 2012 11:29:21 -0400 Subject: [PATCH] fuzzy: use the new print_obj function --- beetsplug/fuzzy_search.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/beetsplug/fuzzy_search.py b/beetsplug/fuzzy_search.py index 398a78811..37a664ac7 100644 --- a/beetsplug/fuzzy_search.py +++ b/beetsplug/fuzzy_search.py @@ -16,7 +16,7 @@ """ import beets from beets.plugins import BeetsPlugin -from beets.ui import Subcommand, decargs, print_ +from beets.ui import Subcommand, decargs, print_obj from beets.util.functemplate import Template import difflib @@ -47,19 +47,16 @@ def fuzzy_list(lib, config, opts, args): query = ' '.join(query).lower() queryMatcher = difflib.SequenceMatcher(b=query) - fmt = opts.format if opts.threshold is not None: threshold = float(opts.threshold) else: threshold = float(conf['threshold']) - if fmt is None: - # If no specific template is supplied, use a default - if opts.album: - fmt = u'$albumartist - $album' - else: - fmt = u'$artist - $album - $title' - template = Template(fmt) + if opts.path: + fmt = '$path' + else: + fmt = opts.format + template = Template(fmt) if fmt else None if opts.album: objs = lib.albums() @@ -68,13 +65,9 @@ def fuzzy_list(lib, config, opts, args): items = filter(lambda i: is_match(queryMatcher, i, album=opts.album, threshold=threshold), objs) - for i in items: - if opts.path: - print_(i.item_dir() if opts.album else i.path) - elif opts.album: - print_(i.evaluate_template(template)) - else: - print_(i.evaluate_template(template, lib)) + + for item in items: + print_obj(item, lib, config, template) if opts.verbose: print(is_match(queryMatcher, i, album=opts.album, verbose=True)[1])