Skip to content
Permalink
Browse files
experiment with progressbars (#769)
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 28, 2014
1 parent 5f0d413 commit eda6cd1c8859ff9bb9a7678bfda9bac07e44f390
Showing with 33 additions and 1 deletion.
  1. +33 −1 nikola/__main__.py
@@ -52,6 +52,38 @@

config = {}

class ProgressBarTestReporter(ExecutedOnlyReporter):

def initialize(self, tasks):
self.taskcount = len(tasks)
self.tasks = tasks
self.done = 0
self.donetasks = []

def execute_task(self, task):
self.done += 1
self.donetasks.append(task)
self.print_ratio('e|' + repr(task))

def skip_uptodate(self, task):
self.done += 1
self.donetasks.append(task)
self.print_ratio('u|' + repr(task))

def skip_ignore(self, task):
self.done += 1
self.donetasks.append(task)
self.print_ratio('i|' + repr(task))

def print_ratio(self, action):
self.write('{0} / {1} = {2:f} ({3})\n'.format(self.done, self.taskcount, float(self.done)/float(self.taskcount), action))

def complete_run(self):
ntasks = self.tasks.values()
for t in self.donetasks:
ntasks.remove(t)
print('LEFTOVER TASKS: {0}'.format(ntasks))
super(ProgressBarTestReporter, self).complete_run()

def main(args=None):
colorful = False
@@ -210,7 +242,7 @@ def load_tasks(self, cmd, opt_values, pos_args):
}
else:
DOIT_CONFIG = {
'reporter': ExecutedOnlyReporter,
'reporter': ProgressBarTestReporter,
}
DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render']
tasks = generate_tasks(

0 comments on commit eda6cd1

Please sign in to comment.