From 9d03981981f5d620a645d35d4a41efaec802608d Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos <skalkoto@grnet.gr> Date: Thu, 11 Dec 2014 11:36:33 +0200 Subject: [PATCH] output: in _Progress class rename output to parent output is a Output class method and using it in _Progress makes the code more confusing. --- image_creator/output/__init__.py | 6 +++--- image_creator/output/cli.py | 4 ++-- image_creator/output/composite.py | 2 +- image_creator/output/dialog.py | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/image_creator/output/__init__.py b/image_creator/output/__init__.py index 4e86a80..f9b5b2d 100644 --- a/image_creator/output/__init__.py +++ b/image_creator/output/__init__.py @@ -51,7 +51,7 @@ class Output(object): def _get_progress(self): """Returns a new Progress object""" progress = self._Progress - progress.output = self + progress.parent = self return progress Progress = property(_get_progress) @@ -61,7 +61,7 @@ class Output(object): def __init__(self, size, title, bar_type='default'): self.size = size self.bar_type = bar_type - self.output.output("%s ..." % title, False) + self.parent.output("%s ..." % title, False) def goto(self, dest): """Move progress to a specific position""" @@ -73,7 +73,7 @@ class Output(object): def success(self, result): """Print a msg after an action is completed successfully""" - self.output.success(result) + self.parent.success(result) def progress_generator(self, message): """A python generator for the progress bar class""" diff --git a/image_creator/output/cli.py b/image_creator/output/cli.py index d938e94..7fe51b0 100644 --- a/image_creator/output/cli.py +++ b/image_creator/output/cli.py @@ -114,7 +114,7 @@ class OutputWthProgress(SimpleOutput): def success(self, result): """Print result after progress has finished""" - self.output.output("\r%s ...\033[K" % self.title, False) - self.output.success(result) + self.parent.output("\r%s ...\033[K" % self.title, False) + self.parent.success(result) # vim: set sta sts=4 shiftwidth=4 sw=4 et ai : diff --git a/image_creator/output/composite.py b/image_creator/output/composite.py index cb78206..51e1996 100644 --- a/image_creator/output/composite.py +++ b/image_creator/output/composite.py @@ -77,7 +77,7 @@ class CompositeOutput(Output): def __init__(self, size, title, bar_type='default'): """Create a progress on each of the added output instances""" self._progresses = [] - for out in self.output._outputs: + for out in self.parent._outputs: self._progresses.append(out.Progress(size, title, bar_type)) def goto(self, dest): diff --git a/image_creator/output/dialog.py b/image_creator/output/dialog.py index be0297b..733a844 100644 --- a/image_creator/output/dialog.py +++ b/image_creator/output/dialog.py @@ -76,25 +76,25 @@ class GaugeOutput(Output): } def __init__(self, size, title, bar_type='default'): - self.output.size = size + self.parent.size = size self.bar_type = bar_type - self.output.msg = "%s ..." % title + self.parent.msg = "%s ..." % title self.goto(0) def _postfix(self): - return self.template[self.bar_type] % self.output.__dict__ + return self.template[self.bar_type] % self.parent.__dict__ def goto(self, dest): """Move progress bar to a specific position""" - self.output.index = dest - self.output.percent = self.output.index * 100 // self.output.size - msg = "%s %s" % (self.output.msg, self._postfix()) - self.output.d.gauge_update(self.output.percent, msg, + self.parent.index = dest + self.parent.percent = self.parent.index * 100 // self.parent.size + msg = "%s %s" % (self.parent.msg, self._postfix()) + self.parent.d.gauge_update(self.parent.percent, msg, update_text=True) def next(self): """Move progress bar one step forward""" - self.goto(self.output.index + 1) + self.goto(self.parent.index + 1) class InfoBoxOutput(Output): -- GitLab