The library mode was slow due to use of item.formatted(), which
runs multiple database queries per item. The --include-keys option
didn't help because it filtered the after the queries had already
happened.
This commit reworks filtering so that we only query the fields
that the user requests. In many cases this can dramatically speed up
execution.
Before:
> /usr/bin/time beet export -l Bob Dylan > /dev/null
13.42user 21.56system 0:35.71elapsed 97%CPU (0avgtext+0avgdata 52396maxresident)k
> /usr/bin/time beet export -l -i artist,title,path Bob Dylan > /dev/null
13.25user 21.17system 0:35.14elapsed 97%CPU (0avgtext+0avgdata 52112maxresident)k
After:
> /usr/bin/time beet export -l Bob Dylan > /dev/null
1.46user 0.09system 0:01.60elapsed 97%CPU (0avgtext+0avgdata 51188maxresident)k
> /usr/bin/time beet export -l -i artist,title,path Bob Dylan > /dev/null
0.50user 0.07system 0:00.58elapsed 97%CPU (0avgtext+0avgdata 50632maxresident)k
Fallout from #2188. Following @jrobeson's suggestion, I just turned the check
in LibModel.__format__ into an assert. This turned up a few badly-behaved
clients, which are also fixed.
* Make emitters produce a pair (dict, Item), in order to preserve the output
at print_data (dict is used if no custom format is specified, Item otherwise).
* Simplify the handling of the paths, printed at the top of print_data. The
path key is removed from the dict entirely and fetched from the Item.
* Add custom output formatting via a format string to InfoPlugin. The command
accepts a formatting string via the "-f" parameter, which is handled by its
CommonOptionsParser and applied during print_data().
* Modify the emitters in order to include an Item into the list of fields, that
is formatted according to the format string if specified.
* Add an argument to allow the user to choose if track lengths are displayed as
raw floats or using a human-readable form (mm:ss), defaulting to human-readable
form.
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.
Goal is smoothing the transition to python 3.
This restores the -v flag affecting plugins. By default, plugin loggers use
the NOTSET level, which just reuses the base `beets` logger level. The level
is only auto-adjusted for the importer when not in verbose mode.