Commits

Adrian Sampson  committed 6afac3f

zero: remove redundant list of dict's keys

  • Participants
  • Parent commits bebc4f3

Comments (0)

Files changed (1)

File beetsplug/zero.py

             'fields': [],
         })
 
-        self.fields = []
         self.patterns = {}
         self.warned = False
 
             if f not in ITEM_KEYS:
                 self._log.error(u'[zero] invalid field: {0}'.format(f))
             else:
-                self.fields.append(f)
                 try:
                     self.patterns[f] = self.config[f].as_str_seq()
                 except confit.NotFoundError:
 
     def write_event(self, item):
         """Listen for write event."""
-        if not self.fields:
+        if not self.patterns:
             self._log.warn(u'[zero] no fields, nothing to do')
             return
-        for fn in self.fields:
+        for fn, patterns in self.patterns.items():
             try:
                 fval = getattr(item, fn)
             except AttributeError:
                 self._log.error(u'[zero] no such field: {0}'.format(fn))
             else:
-                if not self.match_patterns(fval, self.patterns[fn]):
+                if not self.match_patterns(fval, patterns):
                     self._log.debug(u'[zero] \"{0}\" ({1}) not match: {2}'
                                     .format(fval, fn, 
-                                            ' '.join(self.patterns[fn])))
+                                            ' '.join(patterns)))
                     continue
                 self._log.debug(u'[zero] \"{0}\" ({1}) match: {2}'
-                                .format(fval, fn, ' '.join(self.patterns[fn])))
+                                .format(fval, fn, ' '.join(patterns)))
                 setattr(item, fn, type(fval)())
                 self._log.debug(u'[zero] {0}={1}'
                                 .format(fn, getattr(item, fn)))