New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
beet fields: Print flexible attributes #1818
beet fields: Print flexible attributes #1818
Conversation
@@ -92,6 +92,15 @@ def _print_rows(names): | |||
print_("Album fields:") | |||
_print_rows(library.Album.all_keys()) | |||
|
|||
def _print_sqlite(query): | |||
[print_(' ' * 2 + dict(zip(row.keys(), row))['key']) for row in query] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a style matter, an imperative loop probably shouldn't be a written as a list comprehension—a normal for loop will likely be more readable.
Also, since this function doesn't close over any state from the outer scope, it should probably be a top-level function (rather than nested).
Great! This seems perfect! I don't think we need a flag—this doesn't indeed seem like it could possibly be slow. If people complain, we can reconsider. |
Did the suggestions. it seems ok now? |
Looks great; thank you! Could you please add some code comments and an entry to the changelog? It might also be worth looking at the docs for the |
@@ -92,6 +97,14 @@ def _print_rows(names): | |||
print_("Album fields:") | |||
_print_rows(library.Album.all_keys()) | |||
|
|||
with lib.transaction() as tx: | |||
print_("Item attributes:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let's change the terminology here and add the word "flexible" for clarity.
I added some code comments to help and the changelog entry.
|
beet fields: Print flexible attributes
This isn't really a generic utility, since it is hard-coded to print the "key" field of the result. So let's pair it with the place it's used.
Great; thanks! It's all merged up. And thanks again for all your contributions lately. I'll send you an invitation to the @beetbox org, so feel free to commit changes directly. PRs are of course still cool if you'd like a code review. |
Tries to solve #544.
I'm not sure if this needs an flag, since isn't slow (at least to me), but would avoid one db access.
If needs, what could be a good single letter/long option?
-x
for--flexattr/--flexible-attributes
?-f
is usuallyformat
, so maybe not-a
is usuallyalbum
Should I add 'flexible' in 'item/album attributes' ?