From 7d879289c1e46e3ef7a8fa1e66ed33d862abc451 Mon Sep 17 00:00:00 2001 From: Philippe Mongeau Date: Sun, 10 Mar 2013 18:00:28 -0400 Subject: [PATCH] fuzzy: add prefix config --- beetsplug/fuzzy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/beetsplug/fuzzy.py b/beetsplug/fuzzy.py index 9ffb50fe4..363122e8d 100644 --- a/beetsplug/fuzzy.py +++ b/beetsplug/fuzzy.py @@ -18,8 +18,8 @@ from beets.plugins import BeetsPlugin from beets.library import PluginQuery from beets.ui import Subcommand, decargs, print_obj -from beets import config from beets import util +import beets import difflib @@ -28,14 +28,15 @@ class FuzzyQuery(PluginQuery): super(FuzzyQuery, self).__init__(field, pattern) # self.field = field self.name = 'PLUGIN' - self.prefix = "~" + self.prefix = beets.config['fuzzy']['prefix'].get() or '~' + self.threshold = beets.config['fuzzy']['threshold'].as_number() or 0.7 def match(self, pattern, val): if pattern is None: return False val = util.as_string(val) queryMatcher = difflib.SequenceMatcher(None, pattern, val) - return queryMatcher.quick_ratio() > config['fuzzy']['threshold'].as_number() + return queryMatcher.quick_ratio() > self.threshold class FuzzyPlugin(BeetsPlugin): @@ -43,6 +44,7 @@ class FuzzyPlugin(BeetsPlugin): super(FuzzyPlugin, self).__init__(self) self.config.add({ 'threshold': 0.7, + 'prefix': '~', }) def queries(self):