Entry and OU are async iterators that do not deplete.
This commit is contained in:
parent
fd729170d3
commit
d0cba75ee0
|
@ -73,6 +73,9 @@ class Entry(object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<{call_if_callable(self, 'name')} {self.dn}>"
|
return f"<{call_if_callable(self, 'name')} {self.dn}>"
|
||||||
|
|
||||||
|
def __aiter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
async def get_children(self):
|
async def get_children(self):
|
||||||
async with self.client.connect(is_async=True) as conn:
|
async with self.client.connect(is_async=True) as conn:
|
||||||
for el in await conn.search(self.dn, 2):
|
for el in await conn.search(self.dn, 2):
|
||||||
|
@ -117,8 +120,12 @@ class Hackers(Entry):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
self._hackers = build_heritage(self, User)
|
self._hackers = build_heritage(self, User)
|
||||||
|
|
||||||
def __aiter__(self):
|
async def __anext__(self):
|
||||||
return self._hackers
|
try:
|
||||||
|
return await self._hackers.__anext__()
|
||||||
|
except StopAsyncIteration:
|
||||||
|
self._hackers = build_heritage(self, User)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class Robots(Entry):
|
class Robots(Entry):
|
||||||
|
@ -133,8 +140,12 @@ class Robots(Entry):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
self._robots = build_heritage(self, Service)
|
self._robots = build_heritage(self, Service)
|
||||||
|
|
||||||
def __aiter__(self):
|
async def __anext__(self):
|
||||||
return self._robots
|
try:
|
||||||
|
return await self._robots.__anext__()
|
||||||
|
except StopAsyncIteration:
|
||||||
|
self._robots = build_heritage(self, Service)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class Congregations(Entry):
|
class Congregations(Entry):
|
||||||
|
@ -149,8 +160,12 @@ class Congregations(Entry):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
self._groups = build_heritage(self, Group, attribute_id="cn")
|
self._groups = build_heritage(self, Group, attribute_id="cn")
|
||||||
|
|
||||||
def __aiter__(self):
|
async def __anext__(self):
|
||||||
return self._groups
|
try:
|
||||||
|
return await self._groups.__anext__()
|
||||||
|
except StopAsyncIteration:
|
||||||
|
self._groups = build_heritage(self, Group, attribute_id="cn")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class User(Hackers):
|
class User(Hackers):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user