-def error(msg, new_line=True):
- nl = "\n" if new_line else ''
- sys.stderr.write(colored.red('Error: %s' % msg) + nl)
-
-
-def warn(msg, new_line=True):
- if not silent:
- nl = "\n" if new_line else ''
- sys.stderr.write(colored.yellow("Warning: %s" % msg) + nl)
-
-
-def success(msg, new_line=True):
- if not silent:
- nl = "\n" if new_line else ''
- sys.stdout.write(colored.green(msg) + nl)
- if not nl:
- sys.stdout.flush()
-
-
-def output(msg="", new_line=True):
- if not silent:
- nl = "\n" if new_line else ''
- sys.stdout.write(msg + nl)
- if not nl:
- sys.stdout.flush()
-
-
-def progress(message=''):
-
- PROGRESS_LENGTH = 32
- MESSAGE_LENGTH = 32
-
- def progress_generator(n=100):
- position = 0
- msg = message.ljust(MESSAGE_LENGTH)
- for i in uiprogress.bar(range(n), msg, PROGRESS_LENGTH, silent):
- if i < position:
- continue
- position = yield
- yield # suppress the StopIteration exception
- return progress_generator