mirror of
https://github.com/beetbox/beets.git
synced 2026-01-09 17:33:51 +01:00
Property for easy FormattedMapping access
This commit is contained in:
parent
e800b46a5d
commit
c08e07d31b
2 changed files with 9 additions and 3 deletions
|
|
@ -393,6 +393,12 @@ class Model(object):
|
|||
"""
|
||||
return FormattedMapping(self, for_path)
|
||||
|
||||
@property
|
||||
def formatted(self):
|
||||
"""A `dict`-like view containing formatted values.
|
||||
"""
|
||||
return self._formatted_mapping(False)
|
||||
|
||||
def evaluate_template(self, template, for_path=False):
|
||||
"""Evaluate a template (a string or a `Template` object) using
|
||||
the object's fields. If `for_path` is true, then no new path
|
||||
|
|
|
|||
|
|
@ -576,8 +576,8 @@ def _field_diff(field, old, new):
|
|||
return None
|
||||
|
||||
# Get formatted values for output.
|
||||
oldstr = old._get_formatted(field)
|
||||
newstr = new._get_formatted(field)
|
||||
oldstr = old.formatted.get(field, u'')
|
||||
newstr = new.formatted.get(field, u'')
|
||||
|
||||
# For strings, highlight changes. For others, colorize the whole
|
||||
# thing.
|
||||
|
|
@ -617,7 +617,7 @@ def show_model_changes(new, old=None, fields=None, always=False):
|
|||
for field in set(new) - set(old):
|
||||
changes.append(u' {0}: {1}'.format(
|
||||
field,
|
||||
colorize('red', new._get_formatted(field))
|
||||
colorize('red', new.formatted[field])
|
||||
))
|
||||
|
||||
# Print changes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue