Skip to content

Commit d6e8889

Browse files
committed
TMP: rich support
1 parent 8b3446c commit d6e8889

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Lib/ldap/response.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def __repr__(self):
7777
return (f"{self.__class__.__name__}(msgid={self.msgid}, "
7878
f"msgtype={self.msgtype}{optional})")
7979

80+
def __rich_repr__(self):
81+
yield "msgid", self.msgid
82+
yield "controls", self.controls, None
83+
8084

8185
class Result(Response):
8286
result: int
@@ -109,6 +113,13 @@ def __repr__(self):
109113
return (f"{self.__class__.__name__}"
110114
f"(msgid={self.msgid}, result={self.result}{optional})")
111115

116+
def __rich_repr__(self):
117+
super().__rich_repr__()
118+
yield "result", self.result
119+
yield "matcheddn", self.matcheddn, ""
120+
yield "message", self.message, ""
121+
yield "referrals", self.referrals, None
122+
112123

113124
class SearchEntry(Response):
114125
msgtype = ldap.RES_SEARCH_ENTRY
@@ -125,6 +136,11 @@ def __new__(cls, msgid, msgtype, controls=None, *,
125136

126137
return instance
127138

139+
def __rich_repr__(self):
140+
super().__rich_repr__()
141+
yield "dn", self.dn
142+
yield "attrs", self.attrs
143+
128144

129145
class SearchReference(Response):
130146
msgtype = ldap.RES_SEARCH_REFERENCE
@@ -139,6 +155,10 @@ def __new__(cls, msgid, msgtype, controls=None, *,
139155

140156
return instance
141157

158+
def __rich_repr__(self):
159+
super().__rich_repr__()
160+
yield "referrals", self.referrals
161+
142162

143163
class SearchResult(Result):
144164
msgtype = ldap.RES_SEARCH_RESULT
@@ -184,12 +204,23 @@ def __repr__(self):
184204
return (f"{self.__class__.__name__}"
185205
f"(msgid={self.msgid}{optional})")
186206

207+
def __rich_repr__(self):
208+
# No super(), we put our values between msgid and controls
209+
yield "msgid", self.msgid
210+
yield "name", self.name, None
211+
yield "value", self.value, None
212+
yield "controls", self.controls, None
213+
187214

188215
class BindResult(Result):
189216
msgtype = ldap.RES_BIND
190217

191218
servercreds: Optional[bytes]
192219

220+
def __rich_repr__(self):
221+
super().__rich_repr__()
222+
yield "servercreds", self.servercreds, None
223+
193224

194225
class ModifyResult(Result):
195226
msgtype = ldap.RES_MODIFY
@@ -267,6 +298,13 @@ def __repr__(self):
267298
return (f"{self.__class__.__name__}"
268299
f"(msgid={self.msgid}, result={self.result}{optional})")
269300

301+
def __rich_repr__(self):
302+
# No super(), we put our values between msgid and controls
303+
yield "msgid", self.msgid
304+
yield "name", self.name, None
305+
yield "value", self.value, None
306+
yield "controls", self.controls, None
307+
270308

271309
class UnsolicitedNotification(ExtendedResult):
272310
msgid = ldap.RES_UNSOLICITED

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy