From 2e4608039c37821d43e8a6a6444dff3489a88730 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 13 Jan 2013 17:25:34 +0100 Subject: [PATCH] builder: make the status_iterator more flexible by supplying a function used to stringify the current item for display --- sphinx/builders/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index 97932c4c7..ad5dc957f 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -98,19 +98,21 @@ class Builder(object): """ raise NotImplementedError - def old_status_iterator(self, iterable, summary, colorfunc=darkgreen): + def old_status_iterator(self, iterable, summary, colorfunc=darkgreen, + stringify_func=str): l = 0 for item in iterable: if l == 0: self.info(bold(summary), nonl=1) l = 1 - self.info(colorfunc(item) + ' ', nonl=1) + self.info(colorfunc(stringify_func(item)) + ' ', nonl=1) yield item if l == 1: self.info() # new version with progress info - def status_iterator(self, iterable, summary, colorfunc=darkgreen, length=0): + def status_iterator(self, iterable, summary, colorfunc=darkgreen, length=0, + stringify_func=str): if length == 0: for item in self.old_status_iterator(iterable, summary, colorfunc): yield item @@ -120,7 +122,7 @@ class Builder(object): for item in iterable: l += 1 s = '%s[%3d%%] %s' % (summary, 100*l/length, - colorfunc(item)) + colorfunc(stringify_func(item))) if self.app.verbosity: s += '\n' else: