Improve comments on formatting inner workings

This commit is contained in:
Bruno Cauet 2015-01-26 09:46:12 +01:00
parent 065cb59ce7
commit 3787f8a1dd
2 changed files with 6 additions and 0 deletions

View file

@ -229,6 +229,8 @@ class WriteError(FileOperationError):
class LibModel(dbcore.Model):
"""Shared concrete functionality for Items and Albums.
"""
_format_config_key = None
"""Config key that specifies how an instance should be formatted"""
def _template_funcs(self):
funcs = DefaultTemplateFunctions(self, self._db).functions()
@ -252,6 +254,7 @@ class LibModel(dbcore.Model):
spec = beets.config[self._format_config_key].get(unicode)
result = self.evaluate_template(spec)
if isinstance(spec, bytes):
# if spec is a byte string then we must return a one as well
return result.encode('utf8')
else:
return result

View file

@ -97,6 +97,9 @@ def print_(*strings):
"""Like print, but rather than raising an error when a character
is not in the terminal's encoding's character set, just silently
replaces it.
If the arguments are strings then they're expected to share the same type:
either bytes or unicode.
"""
if strings:
if not isinstance(strings[0], basestring):