Delete 'None' properties from media file

This commit is contained in:
Thomas Scholtes 2014-04-10 14:35:37 +02:00
parent 90dbefabd3
commit d44adea9d3

View file

@ -1353,12 +1353,16 @@ class MediaFile(object):
"""Set all field values from a dictionary.
For any key in `dict` that is also a field to store tags the
method retrieves the corresponding value from `dict` and
updates the `MediaFile`.
method retrieves the corresponding value from `dict` and updates
the `MediaFile`. If a key has the value `None`, the
corresponding property is deleted from the `MediaFile`.
"""
for field in self.fields():
if field in dict:
setattr(self, field, dict[field])
if dict[field] is None:
delattr(self, field)
else:
setattr(self, field, dict[field])
# Field definitions.