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

Function apply_

beetsplug/edit.py:123–138  ·  view source on GitHub ↗

Set the fields of a `dbcore.Model` object according to a dictionary. This is the opposite of `flatten`. The `data` dictionary should have strings as values.

(obj, data)

Source from the content-addressed store, hash-verified

121
122
123def apply_(obj, data):
124 """Set the fields of a `dbcore.Model` object according to a
125 dictionary.
126
127 This is the opposite of `flatten`. The `data` dictionary should have
128 strings as values.
129 """
130 for key, value in data.items():
131 if _safe_value(obj, key, value):
132 # A safe value *stayed* represented as a safe type. Assign it
133 # directly.
134 obj[key] = value
135 else:
136 # Either the field was stringified originally or the user changed
137 # it from a safe type to an unsafe one. Parse it as a string.
138 obj.set_parse(key, str(value))
139
140
141class EditPlugin(plugins.BeetsPlugin):

Callers 1

apply_dataMethod · 0.85

Calls 3

_safe_valueFunction · 0.85
set_parseMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected