Decodes an IMAP SEARCH response.
Source code in email_profile/clients/imap/parser.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177 | class SearchParser:
"""Decodes an IMAP SEARCH response."""
__slots__ = ("_uids",)
def __init__(self, data: list) -> None:
if not data or not data[0]:
self._uids: list[str] = []
else:
raw = data[0]
text = (
raw.decode("utf-8", errors="replace")
if isinstance(raw, bytes)
else str(raw)
)
self._uids = text.split()
def uids(self) -> list[str]:
return list(self._uids)
def count(self) -> int:
return len(self._uids)
def is_empty(self) -> bool:
return len(self._uids) == 0
def __bool__(self) -> bool:
return len(self._uids) > 0
def __repr__(self) -> str:
return f"SearchParser({self.count()} uids)"
|
__slots__ = ('_uids',)
class-attribute
instance-attribute
__bool__()
Source code in email_profile/clients/imap/parser.py
| def __bool__(self) -> bool:
return len(self._uids) > 0
|
__init__(data)
Source code in email_profile/clients/imap/parser.py
152
153
154
155
156
157
158
159
160
161
162 | def __init__(self, data: list) -> None:
if not data or not data[0]:
self._uids: list[str] = []
else:
raw = data[0]
text = (
raw.decode("utf-8", errors="replace")
if isinstance(raw, bytes)
else str(raw)
)
self._uids = text.split()
|
__repr__()
Source code in email_profile/clients/imap/parser.py
| def __repr__(self) -> str:
return f"SearchParser({self.count()} uids)"
|
count()
Source code in email_profile/clients/imap/parser.py
| def count(self) -> int:
return len(self._uids)
|
is_empty()
Source code in email_profile/clients/imap/parser.py
| def is_empty(self) -> bool:
return len(self._uids) == 0
|
uids()
Source code in email_profile/clients/imap/parser.py
| def uids(self) -> list[str]:
return list(self._uids)
|