Skip to content

Commit ade47c7

Browse files
author
zmoody
committed
Rework iter and add next
1 parent 1918350 commit ade47c7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pynetbox/core/response.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ def __init__(self, endpoint, request, **kwargs):
7878
self._response_cache = []
7979

8080
def __iter__(self):
81-
for i in self._response_cache:
82-
yield self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
81+
if self._response_cache:
82+
yield self.endpoint.return_obj(
83+
self._response_cache.pop(), self.endpoint.api, self.endpoint
84+
)
8385
for i in self.response:
8486
yield self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
8587

8688
def __next__(self):
87-
for i in self._response_cache:
88-
return self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
89-
for i in self.response:
90-
return self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
89+
for i in self:
90+
return i
9191

9292
def __len__(self):
9393
try:

0 commit comments

Comments
 (0)