[repl] move format_collection from repl to ifromatter

This commit is contained in:
Bezleputh 2014-06-22 18:51:00 +02:00 committed by Romain Bignon
commit 7b5ab26d0f
2 changed files with 22 additions and 13 deletions

View file

@ -203,6 +203,16 @@ class IFormatter(object):
"""
return NotImplementedError()
def format_collection(self, collection, only):
"""
Format a collection to be human-readable.
:param collection: collection to format
:type collection: BaseCollection
:rtype: str
"""
return NotImplementedError()
class PrettyFormatter(IFormatter):
def format_obj(self, obj, alias):
@ -230,6 +240,16 @@ class PrettyFormatter(IFormatter):
def get_description(self, obj):
return None
def format_collection(self, collection, only):
if only is False or collection.basename in only:
if collection.basename and collection.title:
self.output(u'%s~ (%s) %s (%s)%s' %
(self.BOLD, collection.basename, collection.title, collection.backend, self.NC))
else:
self.output(u'%s~ (%s) (%s)%s' %
(self.BOLD, collection.basename, collection.backend, self.NC))
def formatter_test_output(Formatter, obj):
"""
Formats an object and returns output as a string.