1. Adrian Sampson
  2. beets

Commits

Adrian Sampson  committed 7dc0cf3

fix inline and rewrite for instance fields

I'm transitioning to using exclusively instance-level fields instead of
class-level fields in plugin objects, but I neglected to bring inline and
rewrite into the future. This manifested as silent inaction on the part of
these plugins.

This change restores the old behavior (for compatibility) but also updates the
plugins to use the new behavior.

  • Participants
  • Parent commits f1d4b19
  • Branches default

Comments (0)

Files changed (3)

File beets/plugins.py

View file
         self.import_stages = []
         self.name = name or self.__module__.split('.')[-1]
         self.config = beets.config[self.name]
-        self.template_funcs = {}
-        self.template_fields = {}
+        if not self.template_funcs:
+            self.template_funcs = {}
+        if not self.template_fields:
+            self.template_fields = {}
 
     def commands(self):
         """Should return a list of beets.ui.Subcommand objects for

File beetsplug/inline.py

View file
         return _func_func
 
 class InlinePlugin(BeetsPlugin):
-    template_fields = {}
-
     def __init__(self):
         super(InlinePlugin, self).__init__()
 
             log.debug(u'adding template field %s' % key)
             func = compile_inline(view.get(unicode))
             if func is not None:
-                InlinePlugin.template_fields[key] = func
+                self.template_fields[key] = func

File beetsplug/rewrite.py

View file
 class RewritePlugin(BeetsPlugin):
     def __init__(self):
         super(RewritePlugin, self).__init__()
-        BeetsPlugin.template_fields = {}
 
         self.config.add({})
 
 
         # Replace each template field with the new rewriter function.
         for fieldname, fieldrules in rules.iteritems():
-            RewritePlugin.template_fields[fieldname] = \
-                    rewriter(fieldname, fieldrules)
+            self.template_fields[fieldname] = rewriter(fieldname, fieldrules)