Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62e79c03b6 | |||
| d14448293b | |||
| 332162775f |
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "dopt-basics"
|
||||
version = "0.2.2"
|
||||
version = "0.2.4"
|
||||
description = "basic cross-project tools for Python-based d-opt projects"
|
||||
authors = [
|
||||
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
|
||||
@ -69,7 +69,7 @@ directory = "reports/coverage"
|
||||
|
||||
|
||||
[tool.bumpversion]
|
||||
current_version = "0.2.2"
|
||||
current_version = "0.2.4"
|
||||
parse = """(?x)
|
||||
(?P<major>0|[1-9]\\d*)\\.
|
||||
(?P<minor>0|[1-9]\\d*)\\.
|
||||
|
||||
@ -24,6 +24,7 @@ class LoadingAnimation:
|
||||
self.ending_text = ending_text
|
||||
self.timeout = timeout
|
||||
self.done: bool = False
|
||||
self.keyboard_interrupt: bool = False
|
||||
|
||||
self._isatty = sys.stdout.isatty()
|
||||
self._do_animation = bool(sys.stdout.isatty())
|
||||
@ -53,16 +54,15 @@ class LoadingAnimation:
|
||||
exc_type: type[Exception],
|
||||
exc_value,
|
||||
tb,
|
||||
) -> bool:
|
||||
) -> None:
|
||||
if exc_type is not None:
|
||||
self.stop(interrupt=True)
|
||||
if exc_type is KeyboardInterrupt:
|
||||
self.keyboard_interrupt = True
|
||||
print("Operation cancelled by user. (KeyboardInterrupt)", flush=True)
|
||||
return True
|
||||
return False
|
||||
return
|
||||
|
||||
self.stop()
|
||||
return False
|
||||
|
||||
def _animation(self) -> None:
|
||||
for frame in cycle(self.frames):
|
||||
@ -81,6 +81,9 @@ class LoadingAnimation:
|
||||
self,
|
||||
interrupt: bool = False,
|
||||
) -> None:
|
||||
if self.done:
|
||||
return
|
||||
|
||||
self.done = True
|
||||
if self._do_animation:
|
||||
self._thread.join()
|
||||
@ -100,6 +103,6 @@ def default_loading(func: Callable[P, T]) -> Callable[P, T]:
|
||||
with LoadingAnimation(loading_txt, ending_text):
|
||||
res = func(*args, **kwargs)
|
||||
|
||||
return res # type: ignore
|
||||
return res
|
||||
|
||||
return wrapper
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user