How to use the yaspin.Spinner function in yaspin

To help you get started, we’ve selected a few yaspin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pavdmyt / yaspin / tests / test_yaspin.py View on Github external
        (Spinner("", 42), default_spinner),
        # Both attrs, not interval
        (Spinner("-\\|/", 0), default_spinner),
        # Both attrs, are set
        (Spinner("-\\|/", 42), Spinner("-\\|/", 42)),
    ],
)
def test_set_spinner(spinner, expected):
    swirl = yaspin(spinner)
    assert swirl.spinner == expected
github pavdmyt / yaspin / tests / test_properties.py View on Github external
def test_spinner_setter(frames, interval):
    swirl = yaspin()
    assert swirl._spinner == default_spinner
    assert isinstance(swirl._frames, str)
    assert swirl._interval == swirl._spinner.interval * 0.001
    assert isinstance(repr(swirl), builtin_str)

    new_spinner = Spinner(frames, interval)
    swirl.spinner = new_spinner
    assert swirl._spinner == swirl._set_spinner(new_spinner)

    if isinstance(swirl._frames, basestring):
        assert isinstance(swirl._frames, str)

    if isinstance(swirl._frames, (list, tuple)):
        assert isinstance(swirl._frames[0], str)

    assert swirl._interval == swirl._spinner.interval * 0.001
    assert isinstance(repr(swirl), builtin_str)
github pavdmyt / yaspin / tests / test_yaspin.py View on Github external
        (Spinner("", 0), default_spinner),
        # Both attrs, not frames
        (Spinner("", 42), default_spinner),
        # Both attrs, not interval
        (Spinner("-\\|/", 0), default_spinner),
        # Both attrs, are set
        (Spinner("-\\|/", 42), Spinner("-\\|/", 42)),
    ],
)
def test_set_spinner(spinner, expected):
    swirl = yaspin(spinner)
    assert swirl.spinner == expected
github pavdmyt / yaspin / tests / test_yaspin.py View on Github external
        (Spinner("-\\|/", 0), default_spinner),
        # Both attrs, are set
        (Spinner("-\\|/", 42), Spinner("-\\|/", 42)),
    ],
)
def test_set_spinner(spinner, expected):
    swirl = yaspin(spinner)
    assert swirl.spinner == expected
github pavdmyt / yaspin / tests / test_properties.py View on Github external
def test_spinner_getter(frames, interval):
    swirl = yaspin()
    assert swirl.spinner == default_spinner

    new_spinner = Spinner(frames, interval)
    swirl.spinner = new_spinner
    assert swirl.spinner == swirl._set_spinner(new_spinner)
github pavdmyt / yaspin / tests / test_in_out.py View on Github external
def test_repr(text, frames, interval):
    sp = Spinner(frames, interval)
    sp = yaspin(sp, text)

    assert isinstance(repr(sp), builtin_str)
github pavdmyt / yaspin / tests / test_yaspin.py View on Github external
        (Spinner("-\\|/", 42), Spinner("-\\|/", 42)),
    ],
)
def test_set_spinner(spinner, expected):
    swirl = yaspin(spinner)
    assert swirl.spinner == expected
github pavdmyt / yaspin / tests / test_in_out.py View on Github external
def test_input_converted_to_unicode(text, frames, interval, reversal, side):
    sp = Spinner(frames, interval)
    sp = yaspin(sp, text, side=side, reversal=reversal)

    if isinstance(sp._frames, basestring):
        assert isinstance(sp._frames, str)

    if isinstance(sp._frames, (list, tuple)):
        assert isinstance(sp._frames[0], str)

    assert isinstance(sp._text, str)
github pavdmyt / yaspin / examples / basic_usage.py View on Github external
def context_manager_line():
    line_spinner = Spinner("-\\|/", 150)
    with yaspin(line_spinner, "line"):
        time.sleep(3)
github IntelAI / nauta / applications / cli / util / spinner.py View on Github external
IS_TERMINAL_INTERACTIVE = sys.stdout.isatty()


def set_frames_string():
    fallback_frames = "\\|/-"
    if get_current_os() == OS.WINDOWS:
        return fallback_frames
    try:
        utf_frames = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
        utf_frames.encode(sys.stdout.encoding)
        return utf_frames
    except UnicodeEncodeError:
        return fallback_frames


NctlSpinner = yaspin.Spinner(frames=set_frames_string(), interval=80)


class DummySpinner(yaspin.core.Yaspin):
    def __init__(self, text: str, *args, **kwargs):
        self.text = text
        super().__init__(text=text, *args, **kwargs)

    def __enter__(self):
        click.echo(self.text)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        pass

    def __call__(self, *args, **kwargs):
        click.echo(self.text)