Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
def kbi_safe_yaspin(*args, **kwargs):
kwargs["sigmap"] = {signal.SIGINT: default_handler}
return Yaspin(*args, **kwargs)
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)