Skip to content

Commit

Permalink
rename decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
rsalmei committed Apr 16, 2020
1 parent dc0f387 commit 70d5919
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions alive_progress/animations/spinners.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from itertools import chain, repeat


def _ensure_length(length, natural=0):
def repeating(length, natural=0):
def wrapper(fn):
@wraps(fn)
def inner(*args, **kwargs):
Expand Down Expand Up @@ -41,7 +41,7 @@ def frame_spinner_factory(*frames):
"""Create a factory of a spinner that delivers frames in sequence."""

def inner_factory(length=None):
@_ensure_length(length, inner_factory.natural)
@repeating(length, inner_factory.natural)
def inner_spinner():
for frame in frames: # TODO change to yield from, when dropping python 2.7
yield frame
Expand All @@ -66,7 +66,7 @@ def inner_factory(length_actual=None):
ratio = float(length_actual) / length if length and length_actual else 1
length_actual = length_actual or inner_factory.natural

@_ensure_length(length_actual)
@repeating(length_actual)
def inner_spinner():
for _ in range(inner_spinner.cycles):
yield next(infinite_ribbon)
Expand Down Expand Up @@ -115,7 +115,7 @@ def inner_factory(length_actual=None):
ratio = float(length_actual) / length if length and length_actual else 1
length_actual = length_actual or inner_factory.natural

@_ensure_length(length_actual)
@repeating(length_actual)
def inner_spinner():
for i, fill in enumerate(right_scroll()):
if i < right_direction_size:
Expand Down Expand Up @@ -161,7 +161,7 @@ def compound_spinner_factory(*spinner_factories):
"""Create a factory of a spinner that combines any other spinners together."""

def inner_factory(length=None):
@_ensure_length(length)
@repeating(length)
def inner_spinner():
for fills in zip(range(inner_spinner.cycles), *players):
yield ''.join(fills[1:])
Expand Down

0 comments on commit 70d5919

Please sign in to comment.