Composable IMAP fetch specification.
Source code in email_profile/clients/imap/fetch.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 | class F:
"""Composable IMAP fetch specification."""
__slots__ = ("_spec",)
def __init__(self, spec: str) -> None:
self._spec = spec
def mount(self) -> str:
return self._spec
def __add__(self, other: F) -> F:
left = self._spec.strip("()")
right = other._spec.strip("()")
return F(f"({left} {right})")
def __repr__(self) -> str:
return f"F({self._spec!r})"
@staticmethod
def rfc822() -> F:
return F("(RFC822)")
@staticmethod
def flags() -> F:
return F("(FLAGS)")
@staticmethod
def all_headers() -> F:
return F("(BODY.PEEK[HEADER])")
@staticmethod
def header(name: str) -> F:
return F(f"(BODY.PEEK[HEADER.FIELDS ({name.upper()})])")
@staticmethod
def headers(*names: str) -> F:
fields = " ".join(n.upper() for n in names)
return F(f"(BODY.PEEK[HEADER.FIELDS ({fields})])")
@staticmethod
def body_text() -> F:
return F("(BODY.PEEK[HEADER] BODY.PEEK[TEXT])")
@staticmethod
def body_peek() -> F:
return F("(BODY.PEEK[])")
@staticmethod
def envelope() -> F:
return F("(ENVELOPE)")
@staticmethod
def size() -> F:
return F("(RFC822.SIZE)")
|
__slots__ = ('_spec',)
class-attribute
instance-attribute
__add__(other)
Source code in email_profile/clients/imap/fetch.py
| def __add__(self, other: F) -> F:
left = self._spec.strip("()")
right = other._spec.strip("()")
return F(f"({left} {right})")
|
__init__(spec)
Source code in email_profile/clients/imap/fetch.py
| def __init__(self, spec: str) -> None:
self._spec = spec
|
__repr__()
Source code in email_profile/clients/imap/fetch.py
| def __repr__(self) -> str:
return f"F({self._spec!r})"
|
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def all_headers() -> F:
return F("(BODY.PEEK[HEADER])")
|
body_peek()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def body_peek() -> F:
return F("(BODY.PEEK[])")
|
body_text()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def body_text() -> F:
return F("(BODY.PEEK[HEADER] BODY.PEEK[TEXT])")
|
envelope()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def envelope() -> F:
return F("(ENVELOPE)")
|
flags()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def flags() -> F:
return F("(FLAGS)")
|
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def header(name: str) -> F:
return F(f"(BODY.PEEK[HEADER.FIELDS ({name.upper()})])")
|
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def headers(*names: str) -> F:
fields = " ".join(n.upper() for n in names)
return F(f"(BODY.PEEK[HEADER.FIELDS ({fields})])")
|
mount()
Source code in email_profile/clients/imap/fetch.py
| def mount(self) -> str:
return self._spec
|
rfc822()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def rfc822() -> F:
return F("(RFC822)")
|
size()
staticmethod
Source code in email_profile/clients/imap/fetch.py
| @staticmethod
def size() -> F:
return F("(RFC822.SIZE)")
|