Skip to content

Commit

Permalink
experiment with progressbars (#769)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 28, 2014
1 parent 5f0d413 commit eda6cd1
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion nikola/__main__.py
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit eda6cd1

Please sign in to comment.