# Path: yaspin/base_spinner.py
# class Spinner:
# 
# Path: yaspin/constants.py
# COLOR_ATTRS = COLOR_MAP.keys()
# 
# COLOR_MAP = {
#     # name: type
#     "blink": "attrs",
#     "bold": "attrs",
#     "concealed": "attrs",
#     "dark": "attrs",
#     "reverse": "attrs",
#     "underline": "attrs",
#     "blue": "color",
#     "cyan": "color",
#     "green": "color",
#     "magenta": "color",
#     "red": "color",
#     "white": "color",
#     "yellow": "color",
#     "on_blue": "on_color",
#     "on_cyan": "on_color",
#     "on_green": "on_color",
#     "on_grey": "on_color",
#     "on_magenta": "on_color",
#     "on_red": "on_color",
#     "on_white": "on_color",
#     "on_yellow": "on_color",
# }
# 
# SPINNER_ATTRS = [
#     "aesthetic",
#     "arc",
#     "arrow",
#     "arrow2",
#     "arrow3",
#     "balloon",
#     "balloon2",
#     "betaWave",
#     "bluePulse",
#     "bounce",
#     "bouncingBall",
#     "bouncingBar",
#     "boxBounce",
#     "boxBounce2",
#     "christmas",
#     "circle",
#     "circleHalves",
#     "circleQuarters",
#     "clock",
#     "dots",
#     "dots10",
#     "dots11",
#     "dots12",
#     "dots2",
#     "dots3",
#     "dots4",
#     "dots5",
#     "dots6",
#     "dots7",
#     "dots8",
#     "dots8Bit",
#     "dots9",
#     "dqpb",
#     "earth",
#     "fingerDance",
#     "fistBump",
#     "flip",
#     "grenade",
#     "growHorizontal",
#     "growVertical",
#     "hamburger",
#     "hearts",
#     "layer",
#     "line",
#     "line2",
#     "material",
#     "mindblown",
#     "monkey",
#     "moon",
#     "noise",
#     "orangeBluePulse",
#     "orangePulse",
#     "pipe",
#     "point",
#     "pong",
#     "runner",
#     "shark",
#     "simpleDots",
#     "simpleDotsScrolling",
#     "smiley",
#     "soccerHeader",
#     "speaker",
#     "squareCorners",
#     "squish",
#     "star",
#     "star2",
#     "timeTravel",
#     "toggle",
#     "toggle10",
#     "toggle11",
#     "toggle12",
#     "toggle13",
#     "toggle2",
#     "toggle3",
#     "toggle4",
#     "toggle5",
#     "toggle6",
#     "toggle7",
#     "toggle8",
#     "toggle9",
#     "triangle",
#     "weather",
# ]
# 
# Path: yaspin/helpers.py
# def to_unicode(text_type, encoding=ENCODING):
#     if isinstance(text_type, bytes):
#         return text_type.decode(encoding)
#     return text_type


import contextlib
import datetime
import functools
import itertools
import signal
import sys
import threading
import time
from typing import List, Set, Union
from termcolor import colored
from .base_spinner import Spinner, default_spinner
from .constants import COLOR_ATTRS, COLOR_MAP, SPINNER_ATTRS
from .helpers import to_unicode
            from .spinners import Spinners  # pylint: disable=import-outside-toplevel
        # https://pypi.python.org/pypi/tqdm#writing-messages
        with self._stdout_lock:
            sys.stdout.write("\r")
            self._clear_line()

            if isinstance(text, (str, bytes)):
                _text = to_unicode(text)
            else:
                _text = str(text)

            # Ensure output is Unicode
            assert isinstance(_text, str)

            sys.stdout.write("{0}\n".format(_text))

    def ok(self, text="OK"):
        """Set Ok (success) finalizer to a spinner."""
        _text = text if text else "OK"
        self._freeze(_text)

    def fail(self, text="FAIL"):
        """Set fail finalizer to a spinner."""
        _text = text if text else "FAIL"
        self._freeze(_text)

    #
    # Protected
    #
    def _freeze(self, final_text):
        """Stop spinner, compose last frame and 'freeze' it."""

# Path: yaspin/base_spinner.py
# class Spinner:
# 
# Path: yaspin/constants.py
# COLOR_ATTRS = COLOR_MAP.keys()
# 
# COLOR_MAP = {
#     # name: type
#     "blink": "attrs",
#     "bold": "attrs",
#     "concealed": "attrs",
#     "dark": "attrs",
#     "reverse": "attrs",
#     "underline": "attrs",
#     "blue": "color",
#     "cyan": "color",
#     "green": "color",
#     "magenta": "color",
#     "red": "color",
#     "white": "color",
#     "yellow": "color",
#     "on_blue": "on_color",
#     "on_cyan": "on_color",
#     "on_green": "on_color",
#     "on_grey": "on_color",
#     "on_magenta": "on_color",
#     "on_red": "on_color",
#     "on_white": "on_color",
#     "on_yellow": "on_color",
# }
# 
# SPINNER_ATTRS = [
#     "aesthetic",
#     "arc",
#     "arrow",
#     "arrow2",
#     "arrow3",
#     "balloon",
#     "balloon2",
#     "betaWave",
#     "bluePulse",
#     "bounce",
#     "bouncingBall",
#     "bouncingBar",
#     "boxBounce",
#     "boxBounce2",
#     "christmas",
#     "circle",
#     "circleHalves",
#     "circleQuarters",
#     "clock",
#     "dots",
#     "dots10",
#     "dots11",
#     "dots12",
#     "dots2",
#     "dots3",
#     "dots4",
#     "dots5",
#     "dots6",
#     "dots7",
#     "dots8",
#     "dots8Bit",
#     "dots9",
#     "dqpb",
#     "earth",
#     "fingerDance",
#     "fistBump",
#     "flip",
#     "grenade",
#     "growHorizontal",
#     "growVertical",
#     "hamburger",
#     "hearts",
#     "layer",
#     "line",
#     "line2",
#     "material",
#     "mindblown",
#     "monkey",
#     "moon",
#     "noise",
#     "orangeBluePulse",
#     "orangePulse",
#     "pipe",
#     "point",
#     "pong",
#     "runner",
#     "shark",
#     "simpleDots",
#     "simpleDotsScrolling",
#     "smiley",
#     "soccerHeader",
#     "speaker",
#     "squareCorners",
#     "squish",
#     "star",
#     "star2",
#     "timeTravel",
#     "toggle",
#     "toggle10",
#     "toggle11",
#     "toggle12",
#     "toggle13",
#     "toggle2",
#     "toggle3",
#     "toggle4",
#     "toggle5",
#     "toggle6",
#     "toggle7",
#     "toggle8",
#     "toggle9",
#     "triangle",
#     "weather",
# ]
# 
# Path: yaspin/helpers.py
# def to_unicode(text_type, encoding=ENCODING):
#     if isinstance(text_type, bytes):
#         return text_type.decode(encoding)
#     return text_type


# Path: yaspin/core.py
import contextlib
import datetime
import functools
import itertools
import signal
import sys
import threading
import time
from typing import List, Set, Union
from termcolor import colored
from .base_spinner import Spinner, default_spinner
from .constants import COLOR_ATTRS, COLOR_MAP, SPINNER_ATTRS
from .helpers import to_unicode
            from .spinners import Spinners  # pylint: disable=import-outside-toplevel

        # https://pypi.python.org/pypi/tqdm#writing-messages
        with self._stdout_lock:
            sys.stdout.write("\r")
            self._clear_line()

            if isinstance(text, (str, bytes)):
                _text = to_unicode(text)
            else:
                _text = str(text)

            # Ensure output is Unicode
            assert isinstance(_text, str)

            sys.stdout.write("{0}\n".format(_text))

    def ok(self, text="OK"):
        """Set Ok (success) finalizer to a spinner."""
        _text = text if text else "OK"
        self._freeze(_text)

    def fail(self, text="FAIL"):
        """Set fail finalizer to a spinner."""
        _text = text if text else "FAIL"
        self._freeze(_text)

    #
    # Protected
    #
    def _freeze(self, final_text):
        """Stop spinner, compose last frame and 'freeze' it."""

        text = to_unicode(final_text)