#!/usr/bin/env python
# https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
# http://aurelio.net/shell/canivete/
# https://stackoverflow.com/questions/27265322/how-to-print-to-console-in-color

import math
import sys

from colorize import Colorize

__author__ = 'Henrique Leal'
__author_email__ = 'hm.leal@hotmail.com'
__version__ = '0.0.2'


c = Colorize()


def gauge(value, max_value, width, danger_zone, suffix):
    if max_value == 0:
        return '[]'

    length = math.ceil(value / max_value * width)

    if length > width:
        length = width

    bars = '|' * length
    if value > danger_zone:
        bars = c.red(bars)
    bars = c.green(bars)
    bars += '-' * (width + 1 - length)

    return '[{0}] {1}'.format(bars, suffix)


class Spinner:
    def __init__(self, message, style=None):
        self.message = message
        self._number = 0
        self.style = self._style(style)

    def run(self):
        self._draw()

    def update_msg(self, message):
        self.message = message

    def _draw(self):
        self._number += 1

        frames = [' {0} '.format(c.light_blue(f)) for f in self.style]

        print('{0}{1}'.format(frames[self._number % len(self.style)], c.grey(self.message)), end='\r', file=sys.stdout, flush=True)

    def _style(self, style):
        if style is not None:
            return style

        if sys.platform == 'win32':
            return ['|','/', '-', '\\']

        return ['◜', '◠', '◝', '◞', '◡', '◟']
        # return ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷']

@@ -218,16 +218,17 @@
 s%0A%0Afrom 
+.
 colorize
@@ -410,16 +410,21 @@
 , suffix
+=None
 ):%0A    i
@@ -1534,8 +1534,236 @@
 ', '%E2%A3%B7'%5D%0A
+%0A%0Aif __name__ == '__main__':%0A    import time%0A%0A    spinner = Spinner('0 Documents')%0A    spinner.run()%0A%0A    for x in range(100):%0A        spinner.update_msg('%7B0%7D Documents'.format(x))%0A        spinner.run()%0A%0A        time.sleep(0.2)%0A

Fix python imports