mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Adding feature for enterprise consumed license (#2626)
Co-authored-by: Enrico Minack <github@enrico.minack.dev>
This commit is contained in:
co-authored by
Enrico Minack
parent
eadc241e07
commit
a7bfdf2d65
+11
-3
@@ -52,8 +52,8 @@ class PaginatedListBase(Generic[T]):
|
||||
def _fetchNextPage(self) -> List[T]:
|
||||
raise NotImplementedError
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.__elements = []
|
||||
def __init__(self, elements: Optional[List[T]] = None) -> None:
|
||||
self.__elements = [] if elements is None else elements
|
||||
|
||||
def __getitem__(self, index: Union[int, slice]) -> Any:
|
||||
assert isinstance(index, (int, slice))
|
||||
@@ -138,8 +138,9 @@ class PaginatedList(PaginatedListBase[T]):
|
||||
firstParams: Any,
|
||||
headers: Optional[Dict[str, str]] = None,
|
||||
list_item: str = "items",
|
||||
firstData: Optional[Any] = None,
|
||||
firstHeaders: Optional[Dict[str, Union[str, int]]] = None,
|
||||
):
|
||||
super().__init__()
|
||||
self.__requester = requester
|
||||
self.__contentClass = contentClass
|
||||
self.__firstUrl = firstUrl
|
||||
@@ -153,6 +154,11 @@ class PaginatedList(PaginatedListBase[T]):
|
||||
self._reversed = False
|
||||
self.__totalCount: Optional[int] = None
|
||||
|
||||
first_page = []
|
||||
if firstData is not None and firstHeaders is not None:
|
||||
first_page = self._getPage(firstData, firstHeaders)
|
||||
super().__init__(first_page)
|
||||
|
||||
@property
|
||||
def totalCount(self) -> int:
|
||||
if not self.__totalCount:
|
||||
@@ -214,7 +220,9 @@ class PaginatedList(PaginatedListBase[T]):
|
||||
"GET", self.__nextUrl, parameters=self.__nextParams, headers=self.__headers
|
||||
)
|
||||
data = data if data else []
|
||||
return self._getPage(data, headers)
|
||||
|
||||
def _getPage(self, data: Any, headers: Dict[str, Any]) -> List[T]:
|
||||
self.__nextUrl = None # type: ignore
|
||||
if len(data) > 0:
|
||||
links = self.__parseLinkHeader(headers)
|
||||
|
||||
Reference in New Issue
Block a user