From bcf2e15d23eb2af2753bbce72bbb24d6a7f69f96 Mon Sep 17 00:00:00 2001 From: Julien Cassette Date: Sun, 30 Jan 2022 16:38:34 +0100 Subject: [PATCH] Move construct_match_queries() to dbcore.Model --- beets/dbcore/db.py | 9 +++++++++ beets/importer.py | 2 +- beets/library.py | 18 ------------------ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index acd131be26..5a5c50057f 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -641,6 +641,15 @@ def set_parse(self, key, string): """ self[key] = self._parse(key, string) + @classmethod + def construct_match_queries(cls, **info): + subqueries = [] + for key, value in info.items(): + # Use slow queries for flexible attributes. + fast = key in cls._fields + subqueries.append(MatchQuery(key, value, fast)) + return subqueries + # Database controller and supporting interfaces. diff --git a/beets/importer.py b/beets/importer.py index 02a9cc43d0..9b2993c6c0 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -527,12 +527,12 @@ def chosen_info(self): (in which case the data comes from the files' current metadata) or APPLY (in which case the data comes from the choice). """ - assert(self.choice_flag in (action.ASIS, action.RETAG, action.APPLY)) if self.choice_flag in (action.ASIS, action.RETAG): likelies, consensus = autotag.current_metadata(self.items) return likelies elif self.choice_flag is action.APPLY: return self.match.info.copy() + assert False def imported_items(self): """Return a list of Items that should be added to the library. diff --git a/beets/library.py b/beets/library.py index 12ea705b62..b913050a4a 100644 --- a/beets/library.py +++ b/beets/library.py @@ -607,15 +607,6 @@ def from_path(cls, path): i.mtime = i.current_mtime() # Initial mtime. return i - @classmethod - def construct_match_queries(cls, **info): - subqueries = [] - for (key, value) in info.items(): - # Use slow queries for flexible attributes. - fast = key in cls._fields - subqueries.append(dbcore.MatchQuery(key, value, fast)) - return subqueries - def duplicates(self, *keys): info = {key: self.get(key) for key in keys} subqueries = self.construct_match_queries(**info) @@ -1156,15 +1147,6 @@ def _getters(cls): getters['albumtotal'] = Album._albumtotal return getters - @classmethod - def construct_match_queries(cls, **info): - subqueries = [] - for (key, value) in info.items(): - # Use slow queries for flexible attributes. - fast = key in cls._fields - subqueries.append(dbcore.MatchQuery(key, value, fast)) - return subqueries - def duplicates(self, *keys): info = {key: self.get(key) for key in keys} subqueries = self.construct_match_queries(**info)