MCPcopy Index your code
hub / github.com/nodejs/node / Cycler

Class Cycler

tools/inspector_protocol/jinja2/utils.py:574–598  ·  view source on GitHub ↗

A cycle helper for templates.

Source from the content-addressed store, hash-verified

572
573@implements_iterator
574class Cycler(object):
575 """A cycle helper for templates."""
576
577 def __init__(self, *items):
578 if not items:
579 raise RuntimeError('at least one item has to be provided')
580 self.items = items
581 self.reset()
582
583 def reset(self):
584 """Resets the cycle."""
585 self.pos = 0
586
587 @property
588 def current(self):
589 """Returns the current item."""
590 return self.items[self.pos]
591
592 def next(self):
593 """Goes one item ahead and returns it."""
594 rv = self.current
595 self.pos = (self.pos + 1) % len(self.items)
596 return rv
597
598 __next__ = next
599
600
601class Joiner(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…