How to use the yaspin.core.Yaspin 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 IntelAI / nauta / applications / cli / util / spinner.py View on Github external
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)

    def hide(self):
        pass
github pavdmyt / yaspin / yaspin / api.py View on Github external
def kbi_safe_yaspin(*args, **kwargs):
    kwargs["sigmap"] = {signal.SIGINT: default_handler}
    return Yaspin(*args, **kwargs)
github pavdmyt / yaspin / yaspin / api.py View on Github external
with yaspin(text="Processing..."):
            some_operations()

        # Context manager with custom sequence
        with yaspin(Spinner('-\\|/', 150)):
            some_operations()

        # As decorator
        @yaspin(text="Loading...")
        def foo():
            time.sleep(5)

        foo()

    """
    return Yaspin(*args, **kwargs)