mirror of
https://github.com/beetbox/beets.git
synced 2026-02-25 16:53:17 +01:00
automatically detect path queries containing / (finishes #146)
This commit is contained in:
parent
fcc2744ac5
commit
7f206baae5
3 changed files with 29 additions and 2 deletions
5
NEWS
5
NEWS
|
|
@ -9,6 +9,11 @@
|
|||
now matches the entire phrase. To match in specified fields, use
|
||||
a construction like this:
|
||||
beet ls "artist:the knife"
|
||||
* Queries can match items from the library by directory. A 'path:'
|
||||
prefix is optional; any query containing a path separator (/ on
|
||||
POSIX systems) is assumed to be a path query. Running
|
||||
"beet ls path/to/music" will show all the music in your library
|
||||
under the specified directory.
|
||||
* Album art is now automatically discovered and copied from the
|
||||
imported directories when available.
|
||||
* The release label for albums and tracks is now fetched from
|
||||
|
|
|
|||
|
|
@ -420,8 +420,14 @@ class CollectionQuery(Query):
|
|||
if not res:
|
||||
continue
|
||||
key, pattern = res
|
||||
if key is None: # no key specified; match any field
|
||||
subqueries.append(AnySubstringQuery(pattern, default_fields))
|
||||
if key is None: # No key specified.
|
||||
if os.sep in pattern:
|
||||
# This looks like a path.
|
||||
subqueries.append(PathQuery(pattern))
|
||||
else:
|
||||
# Match any field.
|
||||
subqueries.append(AnySubstringQuery(pattern,
|
||||
default_fields))
|
||||
elif key.lower() == 'comp': # a boolean field
|
||||
subqueries.append(BooleanQuery(key.lower(), pattern))
|
||||
elif key.lower() == 'path':
|
||||
|
|
|
|||
|
|
@ -258,6 +258,22 @@ class PathQueryTest(unittest.TestCase, AssertsMixin):
|
|||
self.assert_matched(results, 'path item')
|
||||
self.assert_done(results)
|
||||
|
||||
def test_slashed_query_matches_path(self):
|
||||
q = '/a/b'
|
||||
results = self.lib.items(q)
|
||||
self.assert_matched(results, 'path item')
|
||||
self.assert_done(results)
|
||||
|
||||
def test_non_slashed_does_not_match_path(self):
|
||||
q = 'c.mp3'
|
||||
results = self.lib.items(q)
|
||||
self.assert_done(results)
|
||||
|
||||
def test_slashes_in_explicit_field_does_not_match_path(self):
|
||||
q = 'title:/a/b'
|
||||
results = self.lib.items(q)
|
||||
self.assert_done(results)
|
||||
|
||||
class BrowseTest(unittest.TestCase, AssertsMixin):
|
||||
def setUp(self):
|
||||
self.lib = beets.library.Library(
|
||||
|
|
|
|||
Loading…
Reference in a new issue