Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: @halo wrapped function can accept halo instance as 'spinner' parameter #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions halo/halo.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,16 @@ def __call__(self, f):

@functools.wraps(f)
def wrapped(*args, **kwargs):
with self:
return f(*args, **kwargs)
try:
if 'spinner' in f.__code__.co_varnames[:f.__code__.co_argcount]:
with self as h:
return f(spinner=h, *args, **kwargs)
else:
with self:
return f(*args, **kwargs)
except ValueError:
with self:
return f(*args, **kwargs)

return wrapped

Expand Down