mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 12:35:19 +01:00
Move construct_match_queries() to dbcore.Model
This commit is contained in:
parent
7633465734
commit
bcf2e15d23
3 changed files with 10 additions and 19 deletions
|
|
@ -641,6 +641,15 @@ class Model:
|
|||
"""
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -527,12 +527,12 @@ class ImportTask(BaseImportTask):
|
|||
(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.
|
||||
|
|
|
|||
|
|
@ -607,15 +607,6 @@ class Item(LibModel):
|
|||
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 @@ class Album(LibModel):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue