IMAPClient 4.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
imapclient/util.py ADDED
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2015, Menno Smits
2
+ # Released subject to the New BSD License
3
+ # Please see http://en.wikipedia.org/wiki/BSD_licenses
4
+
5
+ import logging
6
+ from typing import Iterator, Optional, Sequence, Tuple, Union
7
+
8
+ from . import exceptions
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ def to_unicode(s: Union[bytes, str]) -> str:
14
+ if isinstance(s, bytes):
15
+ try:
16
+ return s.decode("ascii")
17
+ except UnicodeDecodeError:
18
+ logger.warning(
19
+ "An error occurred while decoding %s in ASCII 'strict' mode. Fallback to "
20
+ "'ignore' errors handling, some characters might have been stripped",
21
+ s,
22
+ )
23
+ return s.decode("ascii", "ignore")
24
+ return s
25
+
26
+
27
+ def to_ints(
28
+ messages: Union[bytes, str, int, Sequence[Union[bytes, str, int]]],
29
+ ) -> Sequence[int]:
30
+ """Convert a sequence of values (such as messages)
31
+ or a single integer value into an sequence of ints
32
+ """
33
+ if not messages:
34
+ return []
35
+ if isinstance(messages, (int, str, bytes)):
36
+ return [int(messages)]
37
+ return [int(i) for i in messages]
38
+
39
+
40
+ def to_bytes(s: Union[bytes, str], charset: str = "ascii") -> bytes:
41
+ if isinstance(s, str):
42
+ return s.encode(charset)
43
+ return s
44
+
45
+
46
+ def assert_imap_protocol(condition: bool, message: Optional[bytes] = None) -> None:
47
+ if not condition:
48
+ msg = "Server replied with a response that violates the IMAP protocol"
49
+ if message:
50
+ # FIXME(jlvillal): This looks wrong as it repeats `msg` twice
51
+ msg += "{}: {}".format(
52
+ msg, message.decode(encoding="ascii", errors="ignore")
53
+ )
54
+ raise exceptions.ProtocolError(msg)
55
+
56
+
57
+ _TupleAtomPart = Union[None, int, bytes]
58
+ _TupleAtom = Tuple[Union[_TupleAtomPart, "_TupleAtom"], ...]
59
+
60
+
61
+ def chunk(lst: _TupleAtom, size: int) -> Iterator[_TupleAtom]:
62
+ for i in range(0, len(lst), size):
63
+ yield lst[i : i + size]
imapclient/version.py ADDED
@@ -0,0 +1,17 @@
1
+ # Copyright (c) 2025, Menno Smits
2
+ # Released subject to the New BSD License
3
+ # Please see http://en.wikipedia.org/wiki/BSD_licenses
4
+
5
+ from importlib import metadata
6
+ from typing import Tuple
7
+
8
+ version = metadata.version("imapclient")
9
+
10
+
11
+ def _make_version_info() -> Tuple[int, int, int, str]:
12
+ major, minor, micro = version.split(".")
13
+ return (int(major), int(minor), int(micro), "final")
14
+
15
+
16
+ # This is for backwards compatibility with older versions of IMAPClient only
17
+ version_info = _make_version_info()
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: IMAPClient
3
+ Version: 4.0.0
4
+ Summary: Easy-to-use, Pythonic and complete IMAP client library
5
+ Author-email: Menno Finlay-Smits <hello@menno.io>
6
+ Maintainer-email: IMAPClient Maintainers <imapclient@groups.io>
7
+ Project-URL: Homepage, https://github.com/mjs/imapclient/
8
+ Keywords: imap,client,email,mail
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Communications :: Email :: Post-Office :: IMAP
16
+ Classifier: Topic :: Internet
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: System :: Networking
19
+ Requires-Python: >=3.8.0
20
+ Description-Content-Type: text/x-rst
21
+ License-File: COPYING
22
+ License-File: AUTHORS.rst
23
+ Dynamic: license-file
24
+
25
+ Essentials
26
+ ----------
27
+ IMAPClient is an easy-to-use, Pythonic and complete IMAP client
28
+ library.
29
+
30
+ ========================= ========================================
31
+ Current version 3.0.1
32
+ Supported Python versions 3.8 - 3.14
33
+ License New BSD
34
+ Project home https://github.com/mjs/imapclient/
35
+ PyPI https://pypi.python.org/pypi/IMAPClient
36
+ Documentation https://imapclient.readthedocs.io/
37
+ Discussions https://github.com/mjs/imapclient/discussions
38
+ Test Status |build master|
39
+ ========================= ========================================
40
+
41
+ .. |build master| image:: https://github.com/mjs/imapclient/actions/workflows/main.yml/badge.svg
42
+ :target: https://github.com/mjs/imapclient/actions
43
+ :alt: master branch
44
+
45
+ Features
46
+ --------
47
+ - Arguments and return values are natural Python types.
48
+ - IMAP server responses are fully parsed and readily usable.
49
+ - IMAP unique message IDs (UIDs) are handled transparently. There is
50
+ no need to call different methods to use UIDs.
51
+ - Escaping for internationalised mailbox names is transparently
52
+ handled. Unicode mailbox names may be passed as input wherever a
53
+ folder name is accepted.
54
+ - Time zones are transparently handled including when the server and
55
+ client are in different zones.
56
+ - Convenience methods are provided for commonly used functionality.
57
+ - Exceptions are raised when errors occur.
58
+
59
+ Example
60
+ -------
61
+
62
+ .. code-block:: python
63
+
64
+ from imapclient import IMAPClient
65
+
66
+ # context manager ensures the session is cleaned up
67
+ with IMAPClient(host="imap.host.org") as client:
68
+ client.login('someone', 'secret')
69
+ client.select_folder('INBOX')
70
+
71
+ # search criteria are passed in a straightforward way
72
+ # (nesting is supported)
73
+ messages = client.search(['NOT', 'DELETED'])
74
+
75
+ # fetch selectors are passed as a simple list of strings.
76
+ response = client.fetch(messages, ['FLAGS', 'RFC822.SIZE'])
77
+
78
+ # `response` is keyed by message id and contains parsed,
79
+ # converted response items.
80
+ for message_id, data in response.items():
81
+ print('{id}: {size} bytes, flags={flags}'.format(
82
+ id=message_id,
83
+ size=data[b'RFC822.SIZE'],
84
+ flags=data[b'FLAGS']))
85
+
86
+ Why IMAPClient?
87
+ ---------------
88
+ You may ask: "why create another IMAP client library for Python?
89
+ Doesn't the Python standard library already have imaplib?".
90
+
91
+ The problem with imaplib is that it's very low-level. It expects
92
+ string values where lists or tuples would be more appropriate and
93
+ returns server responses almost unparsed. As IMAP server responses can
94
+ be quite complex this means everyone using imaplib ends up writing
95
+ their own fragile parsing routines.
96
+
97
+ Also, imaplib doesn't make good use of exceptions. This means you need
98
+ to check the return value of each call to imaplib to see if what you
99
+ just did was successful.
100
+
101
+ IMAPClient actually uses imaplib internally. This may change at some
102
+ point in the future.
103
+
104
+ Installing IMAPClient
105
+ ---------------------
106
+ IMAPClient is listed on PyPI and can be installed with `uv
107
+ <https://docs.astral.sh/uv/>`_::
108
+
109
+ uv add imapclient
110
+
111
+ More installation methods are described in the documentation.
112
+
113
+ Documentation
114
+ -------------
115
+ IMAPClient's manual is available at http://imapclient.readthedocs.io/.
116
+ Release notes can be found at
117
+ http://imapclient.readthedocs.io/#release-history.
118
+
119
+ See the `examples` directory in the root of project source for
120
+ examples of how to use IMAPClient.
121
+
122
+ Current Status
123
+ --------------
124
+ You should feel confident using IMAPClient for production purposes.
125
+
126
+ In order to clearly communicate version compatibility, IMAPClient
127
+ will strictly adhere to the `Semantic Versioning <http://semver.org>`_
128
+ scheme from version 1.0 onwards.
129
+
130
+ The project's home page is https://github.com/mjs/imapclient/ (this
131
+ currently redirects to the IMAPClient Github site). Details about
132
+ upcoming versions and planned features/fixes can be found in the issue
133
+ tracker on Github. The maintainers also blog about IMAPClient
134
+ news. Those articles can be found `here
135
+ <http://menno.io/tags/imapclient>`_.
136
+
137
+ Discussions
138
+ -----------
139
+ `Github Discussions`_ can be used to ask questions, propose changes or praise
140
+ the project maintainers :)
141
+
142
+ .. _`Github Discussions`: https://github.com/mjs/imapclient/discussions
143
+
144
+ Working on IMAPClient
145
+ ---------------------
146
+ The `contributing documentation
147
+ <http://imapclient.rtfd.io/en/master/contributing.html>`_ contains
148
+ information for those interested in improving IMAPClient.
149
+
150
+ IMAP Servers
151
+ ------------
152
+ IMAPClient is heavily tested against Dovecot, Gmail, Fastmail.fm
153
+ (who use a modified Cyrus implementation), Office365 and Yahoo. Access
154
+ to accounts on other IMAP servers/services for testing would be
155
+ greatly appreciated.
156
+
157
+ Interactive Console
158
+ -------------------
159
+ This script connects an IMAPClient instance using the command line
160
+ args given and starts an interactive session. This is useful for
161
+ exploring the IMAPClient API and testing things out, avoiding the
162
+ steps required to set up an IMAPClient instance.
163
+
164
+ The IPython shell is used if it is installed. Otherwise the
165
+ code.interact() function from the standard library is used.
166
+
167
+ The interactive console functionality can be accessed by running the
168
+ ``imapclient-interact`` script that is installed alongside IMAPClient,
169
+ or by invoking the interact module like this::
170
+
171
+ uv run python -m imapclient.interact ...
172
+
173
+ "Live" Tests
174
+ ------------
175
+ IMAPClient includes a series of live, functional tests which exercise
176
+ it against a live IMAP account. These are useful for ensuring
177
+ compatibility with a given IMAP server implementation.
178
+
179
+ The livetest functionality is run using the ``imapclient-livetest``
180
+ script that is installed alongside IMAPClient::
181
+
182
+ uv run imapclient-livetest <livetest.ini> [ optional unittest arguments ]
183
+
184
+ The configuration file format is
185
+ `described in the main documentation <http://imapclient.rtfd.io/#configuration-file-format>`_.
186
+
187
+ **WARNING**: The operations used by livetest are destructive and could
188
+ cause unintended loss of data. That said, as of version 0.9, livetest
189
+ limits its activity to a folder it creates and subfolders of that
190
+ folder. It *should* be safe to use with any IMAP account but please
191
+ don't run livetest against a truly important IMAP account.
192
+
193
+ Please include the output of imapclient-livetest with an issue if it
194
+ fails to run successfully against a particular IMAP server. Reports of
195
+ successful runs are also welcome. Please include the type and version
196
+ of the IMAP server, if known.
@@ -0,0 +1,25 @@
1
+ imapclient/__init__.py,sha256=N96_430nCNSDk-WYpZ9Yboh6myie1GtSnTBFGRC96YM,495
2
+ imapclient/config.py,sha256=qqWOvPRG5FzoNkYzQ_aqE0xKCGRpOkhbAxccB3xMdHE,6611
3
+ imapclient/datetime_util.py,sha256=ag3fmKcDbVvFMPQqKdwR8S1qgLOoIMIrEhV4qFNUKqs,2284
4
+ imapclient/exceptions.py,sha256=okd1TpswEsKv05pLXwC9Dvjq-lPOS7T0FlKW_7KeBXo,1193
5
+ imapclient/fixed_offset.py,sha256=fkfjpEIOYl_BDbA81g8xuY_tAZzBGnsqccx-szpPW1s,1298
6
+ imapclient/imap4.py,sha256=VVC0D07WulqG2MYYFrKE-O5l_zk8JTlZ88astlqkHjI,620
7
+ imapclient/imap_utf7.py,sha256=7ldAI_4rK6EOkkPJV14NIZl45mQyO64aTzcIxQ3si9E,3703
8
+ imapclient/imapclient.py,sha256=OPxW5QBz1rZwq43lRG6XB2TgD-0t87Ho4yiKRxW8Lus,74702
9
+ imapclient/interact.py,sha256=uXgm79QF3cxhyVNqdn7Zbn0JKRPLOtYvZ46EpzzJ_xM,4037
10
+ imapclient/livetest.py,sha256=fUj7hNroPyNNY935A78toFRqWzwE6zsZubu6h51GbYc,43220
11
+ imapclient/response_lexer.py,sha256=gBBSlqIHv_C9bHMFE9aXrqPqJRdXERjEDRVfyc0dF9E,5845
12
+ imapclient/response_parser.py,sha256=smOMV0R9U_T1hOmnZJGFuSa1Mp6eFFARKerAQTJl4Z0,9025
13
+ imapclient/response_types.py,sha256=rKw-PzqzGGRw7PSAwiUPMSHSnY3vLy8hI9HHFTtexPc,5476
14
+ imapclient/testable_imapclient.py,sha256=CPJ2BuNJfiAyWcZ5DecsJoi_o6wnfePhLCTDBc6s7P0,1191
15
+ imapclient/tls.py,sha256=nJFS1WVMw9gNnNuybPn9xU3QH92pcTK_BXs0deHrkWI,1233
16
+ imapclient/typing_imapclient.py,sha256=PTj6q6SAcJeEwwV9UdVbLV-5XxdPG6ezQ7_kCUiwKBs,115
17
+ imapclient/util.py,sha256=82tRZAq0IgcjOnE2I39k151-cYM1COh3T9D5djxiMRo,1943
18
+ imapclient/version.py,sha256=PIpDJHwOJ6SrPYsK0yhmaR_FvuzQVWJTmJ68PMLPjT8,504
19
+ imapclient-4.0.0.dist-info/licenses/AUTHORS.rst,sha256=IDCbsOmsmvoRu7du6xjwrU5t5I-OoNavwt6q9IWJY8E,917
20
+ imapclient-4.0.0.dist-info/licenses/COPYING,sha256=NHLfcEugl9DSTplK0wgKxQS2ZAK6uJf6N06zG-mk7Js,1484
21
+ imapclient-4.0.0.dist-info/METADATA,sha256=zbzCIZotECVbVdZjW2Ey9A0GMoYa-pIBDhcdhDMDxqQ,7525
22
+ imapclient-4.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
23
+ imapclient-4.0.0.dist-info/entry_points.txt,sha256=d2Wo2nDiKrERIYpyUCQQheLqezUsBeIGW_i7LXH6Byc,112
24
+ imapclient-4.0.0.dist-info/top_level.txt,sha256=pf_BiuslDCnFXY3K-jy6peSBOfJWXGH17SDmDGcBqMI,11
25
+ imapclient-4.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ imapclient-interact = imapclient.interact:main
3
+ imapclient-livetest = imapclient.livetest:main
@@ -0,0 +1,51 @@
1
+ IMAPClient was created by Menno Finlay-Smits <inbox@menno.io>. The
2
+ project is now maintained by Nicolas Le Manchet and Menno
3
+ Finlay-Smits.
4
+
5
+ Many thanks go to the following people for their help with this
6
+ project:
7
+
8
+ - Maxime Lorant
9
+ - Mathieu Agopian
10
+ - Chris Arndt
11
+ - Jp Calderone
12
+ - John Louis del Rosario
13
+ - Dave Eckhardt
14
+ - Eben Freeman
15
+ - Helder Guerreiro
16
+ - Mark Hammond
17
+ - Johannes Heckel
18
+ - Thomas Jost
19
+ - Lukasz Mierzwa
20
+ - Naveen Nathan
21
+ - Brian Neal
22
+ - Phil Peterson
23
+ - Aviv Salem
24
+ - Andrew Scheller
25
+ - Thomas Steinacher
26
+ - Zac Witte
27
+ - Hans-Peter Jansen
28
+ - Carson Ip
29
+ - Jonny Hatch
30
+ - Jasper Spaans
31
+ - Fabio Manganiello
32
+ - Samir M
33
+ - Devin Bayer
34
+ - Mantas Mikulėnas
35
+ - @zrose584
36
+ - Michał Górny
37
+ - François Deppierraz
38
+ - Jasper Spaans
39
+ - Boni Lindsley
40
+ - Tobias Kölling
41
+ - @pinoatrome
42
+ - Shoaib Ahmed
43
+ - John Villalovos
44
+ - Claude Paroz
45
+ - Stefan Wójcik
46
+ - Andrzej Bartosiński
47
+ - @axoroll7
48
+ - Sean Whalen
49
+ - Peter Wienemann
50
+ - Arnout Engelen
51
+
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2014, Menno Smits
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of Menno Smits nor the names of its
12
+ contributors may be used to endorse or promote products derived
13
+ from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL MENNO SMITS BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ imapclient