Skip to content
Snippets Groups Projects
Commit 1ea7fc2e authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Make progress class contain and Ouput instance

This is handy because now progress class can print using the output
methods of it's output class
parent 574f2712
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ def output(msg='', new_line=True): ...@@ -70,6 +70,7 @@ def output(msg='', new_line=True):
class Output(object): class Output(object):
def error(self, msg, new_line=True): def error(self, msg, new_line=True):
error(msg, new_line, False) error(msg, new_line, False)
...@@ -82,9 +83,16 @@ class Output(object): ...@@ -82,9 +83,16 @@ class Output(object):
def output(self, msg='', new_line=True): def output(self, msg='', new_line=True):
output(msg, new_line) output(msg, new_line)
class Progress(object): def _get_progress(self):
progress = self._Progress
progress.output = self
return progress
Progress = property(_get_progress)
class _Progress(object):
def __init__(self, title, bar_type='default'): def __init__(self, title, bar_type='default'):
output("%s..." % title, False) self.output.output("%s..." % title, False)
def goto(self, dest): def goto(self, dest):
pass pass
...@@ -93,7 +101,7 @@ class Output(object): ...@@ -93,7 +101,7 @@ class Output(object):
pass pass
def success(self, result): def success(self, result):
sucess(result) self.output.success(result)
def progress_generator(self, message): def progress_generator(self, message):
def generator(n): def generator(n):
...@@ -121,7 +129,7 @@ class Output_wth_colors(Output): ...@@ -121,7 +129,7 @@ class Output_wth_colors(Output):
class Output_wth_progress(Output_wth_colors): class Output_wth_progress(Output_wth_colors):
class Progress(Bar): class _Progress(Bar):
MESSAGE_LENGTH = 30 MESSAGE_LENGTH = 30
template = { template = {
...@@ -133,7 +141,7 @@ class Output_wth_progress(Output_wth_colors): ...@@ -133,7 +141,7 @@ class Output_wth_progress(Output_wth_colors):
} }
def __init__(self, title, bar_type='default'): def __init__(self, title, bar_type='default'):
super(Output_wth_progress.Progress, self).__init__() super(Output_wth_progress._Progress, self).__init__()
self.title = title self.title = title
self.fill = '#' self.fill = '#'
self.bar_prefix = ' [' self.bar_prefix = ' ['
...@@ -142,8 +150,8 @@ class Output_wth_progress(Output_wth_colors): ...@@ -142,8 +150,8 @@ class Output_wth_progress(Output_wth_colors):
self.suffix = self.template[bar_type] self.suffix = self.template[bar_type]
def success(self, result): def success(self, result):
output("\r%s... \033[K" % self.title, False) self.output.output("\r%s... \033[K" % self.title, False)
success(result) self.output.success(result)
class Silent(Output): class Silent(Output):
...@@ -156,12 +164,6 @@ class Silent(Output): ...@@ -156,12 +164,6 @@ class Silent(Output):
def output(self, msg='', new_line=True): def output(self, msg='', new_line=True):
pass pass
class Progress(Output.Progress):
def __init__(self, title, bar_type='default'):
pass
def success(self, result):
pass
class Silent_wth_colors(Silent): class Silent_wth_colors(Silent):
def error(self, msg, new_line=True): def error(self, msg, new_line=True):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment