mirror of
https://github.com/beetbox/beets.git
synced 2026-01-04 23:12:51 +01:00
Fields: Print flexible attributes
This commit is contained in:
parent
f0818919ac
commit
ff01015b61
1 changed files with 17 additions and 0 deletions
|
|
@ -79,6 +79,14 @@ def _do_query(lib, query, album, also_items=True):
|
|||
return items, albums
|
||||
|
||||
|
||||
def _print_sqlite(query):
|
||||
"""Gets the result of the query, transforms the sqlite3.Row in dictionary
|
||||
entries and print the values of it, with identation of 2 spaces.
|
||||
"""
|
||||
for row in query:
|
||||
print_(' ' * 2 + dict(zip(row.keys(), row))['key'])
|
||||
|
||||
|
||||
# fields: Shows a list of available fields for queries and format strings.
|
||||
|
||||
def fields_func(lib, opts, args):
|
||||
|
|
@ -92,6 +100,15 @@ def fields_func(lib, opts, args):
|
|||
print_("Album fields:")
|
||||
_print_rows(library.Album.all_keys())
|
||||
|
||||
with lib.transaction() as tx:
|
||||
# The SQL uses the DISTINCT to get unique values from the query
|
||||
unique_fields = 'SELECT DISTINCT key FROM (%s)'
|
||||
|
||||
print_("Item flexible attributes:")
|
||||
_print_sqlite(tx.query(unique_fields % library.Item._flex_table))
|
||||
|
||||
print_("Album flexible attributes:")
|
||||
_print_sqlite(tx.query(unique_fields % library.Album._flex_table))
|
||||
|
||||
fields_cmd = ui.Subcommand(
|
||||
'fields',
|
||||
|
|
|
|||
Loading…
Reference in a new issue