MCPcopy Index your code
hub / github.com/commandoperator/cmdop-sdk / _paginate_cursor

Method _paginate_cursor

python/src/cmdop/resources/base.py:57–77  ·  view source on GitHub ↗

Yield each cursor page; follow ``next_cursor`` until exhausted. Works over both ``MachineList`` (next_cursor + has_more) and ``ScheduleRunList`` (next_cursor only).

(
        self,
        fetch_page: Callable[[str | None], Awaitable[Any]],
    )

Source from the content-addressed store, hash-verified

55 # -- pagination helpers ------------------------------------------------
56
57 async def _paginate_cursor(
58 self,
59 fetch_page: Callable[[str | None], Awaitable[Any]],
60 ) -> AsyncIterator[Any]:
61 """Yield each cursor page; follow ``next_cursor`` until exhausted.
62
63 Works over both ``MachineList`` (next_cursor + has_more) and
64 ``ScheduleRunList`` (next_cursor only).
65 """
66 cursor: str | None = None
67 while True:
68 page = await fetch_page(cursor)
69 yield page
70 next_cursor = getattr(page, "next_cursor", "") or None
71 if not next_cursor:
72 return
73 # has_more is only present on MachineList; absent (truthy default) elsewhere.
74 has_more_field = page.DESCRIPTOR.fields_by_name.get("has_more")
75 if has_more_field is not None and not getattr(page, "has_more", True):
76 return
77 cursor = next_cursor
78
79 async def _paginate_offset(
80 self,

Callers 2

pages_runsMethod · 0.80
pagesMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected