How to use the yaspin.base_spinner.default_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
        (namedtuple("Spinner", "frames")("-\\|/"), default_spinner),
        # not hasattr(spinner, "frames") and hasattr(spinner, "interval")
        (namedtuple("Spinner", "interval")(42), default_spinner),
        # Both attrs, not set
        (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_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 / yaspin / core.py View on Github external
def _set_spinner(spinner):
        if hasattr(spinner, "frames") and hasattr(spinner, "interval"):
            if not spinner.frames or not spinner.interval:
                sp = default_spinner
            else:
                sp = spinner
        else:
            sp = default_spinner

        return sp
github pavdmyt / yaspin / yaspin / core.py View on Github external
def _set_spinner(spinner):
        if hasattr(spinner, "frames") and hasattr(spinner, "interval"):
            if not spinner.frames or not spinner.interval:
                sp = default_spinner
            else:
                sp = spinner
        else:
            sp = default_spinner

        return sp