-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Formatted modify and import --set-field. #4095
Changes from 4 commits
636e36e
819ba73
5824d46
a2030d1
795bc2e
0456c8f
7af40db
dad918e
b207224
fb9e95b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1411,9 +1411,6 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): | |
# Parse key=value specifications into a dictionary. | ||
model_cls = library.Album if album else library.Item | ||
|
||
for key, value in mods.items(): | ||
mods[key] = model_cls._parse(key, value) | ||
|
||
# Get the items to modify. | ||
items, albums = _do_query(lib, query, album, False) | ||
objs = albums if album else items | ||
|
@@ -1424,7 +1421,9 @@ def modify_items(lib, mods, dels, query, write, move, album, confirm): | |
.format(len(objs), 'album' if album else 'item')) | ||
changed = [] | ||
for obj in objs: | ||
if print_and_modify(obj, mods, dels) and obj not in changed: | ||
obj_mods = {key: model_cls._parse(key, format(obj, value)) | ||
for key, value in mods.items()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It occurs to me that we are losing a couple of optimizations by moving this logic inside the loop:
I propose we attempt to address 1 now, as part of this PR, and create a separate issue for addressing item 2. The former should (hopefully) be easy. The latter will require a bit more complexity and IMO is not really necessary to ship this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like @Duncaen added a couple new commits to this PR, is this review still accurate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No; looks like this is now rearranged a bit! I think this is due for another look—it may be ready to go as-is? |
||
if print_and_modify(obj, obj_mods, dels) and obj not in changed: | ||
changed.append(obj) | ||
|
||
# Still something to do? | ||
|
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.
Looking a little closer, I couldn't quite grok what the effect of using
set_parse
instead of just ordinary item assignment would be. Just out of curiosity, did you run into any situations where this behaved different?I notice that
beet modify
usesprint_and_modify
, which in turn usesobj.update
, which I assume will eventually end up using ordinary attribute assignment. Is there any chance thatbeet modify
will now behave differently from setting attributes on import?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.
Oops; I now see that we were explicitly using
_parse
to get this effect inbeet modify
, so this is actually now more consistent than it was before. Yay!