MCPcopy
hub / github.com/beetbox/beets / do_query

Function do_query

beets/ui/commands/utils.py:6–29  ·  view source on GitHub ↗

For commands that operate on matched items, performs a query and returns a list of matching items and a list of matching albums. (The latter is only nonempty when album is True.) Raises a UserError if no items match. also_items controls whether, when fetching albums, the associated i

(lib, query, album, also_items=True)

Source from the content-addressed store, hash-verified

4
5
6def do_query(lib, query, album, also_items=True):
7 """For commands that operate on matched items, performs a query
8 and returns a list of matching items and a list of matching
9 albums. (The latter is only nonempty when album is True.) Raises
10 a UserError if no items match. also_items controls whether, when
11 fetching albums, the associated items should be fetched also.
12 """
13 if album:
14 albums = list(lib.albums(query))
15 items = []
16 if also_items:
17 for al in albums:
18 items += al.items()
19
20 else:
21 albums = []
22 items = list(lib.items(query))
23
24 if album and not albums:
25 raise UserError("No matching albums found.")
26 if not album and not items:
27 raise UserError("No matching items found.")
28
29 return items, albums

Callers 9

check_do_queryMethod · 0.90
test_query_emptyMethod · 0.90
_edit_commandMethod · 0.90
move_itemsFunction · 0.85
write_itemsFunction · 0.85
remove_itemsFunction · 0.85
modify_itemsFunction · 0.85
update_itemsFunction · 0.85

Calls 3

UserErrorClass · 0.90
albumsMethod · 0.45
itemsMethod · 0.45

Tested by 3

check_do_queryMethod · 0.72
test_query_emptyMethod · 0.72