Skip to content

Commit

Permalink
Move construct_match_queries() to dbcore.Model
Browse files Browse the repository at this point in the history
  • Loading branch information
jcassette committed Jan 30, 2022
1 parent 7633465 commit bcf2e15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
9 changes: 9 additions & 0 deletions beets/dbcore/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion beets/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 0 additions & 18 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bcf2e15

Please sign in to comment.