Skip to content

Commit ad2a042

Browse files
committed
Include a decent example in README & correct many errors
There were many things in the README which were no longer true due to recent changes to the project.
1 parent 6068368 commit ad2a042

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed

README.rst

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,33 @@ Features
4444
- Convenience methods are provided for commonly used functionality.
4545
- Exceptions are raised when errors occur.
4646

47+
Example
48+
-------
49+
50+
.. code-block:: python
51+
52+
from imapclient import IMAPClient
53+
54+
# context manager ensures the session is cleaned up
55+
with imapclient.IMAPClient(host="imap.host.org") as client:
56+
client.login('someone', 'secret')
57+
client.select_folder('INBOX')
58+
59+
# search criteria are passed in a straightforward way
60+
# (nesting is supported)
61+
messages = client.search(['NOT', 'DELETED'])
62+
63+
# fetch selectors are passed as a simple list of strings.
64+
response = client.fetch(messages, ['FLAGS', 'RFC822.SIZE'])
65+
66+
# `response` is keyed by message id and contains parsed,
67+
# converted response items.
68+
for message_id, data in response.items():
69+
print('{id}: {size} bytes, flags={flags}'.format(
70+
id=message_id,
71+
size=data[b'RFC822.SIZE'],
72+
flags=data[b'FLAGS']))
73+
4774
Why IMAPClient?
4875
---------------
4976
You may ask: "why create another IMAP client library for Python?
@@ -53,7 +80,7 @@ The problem with imaplib is that it's very low-level. It expects
5380
string values where lists or tuples would be more appropriate and
5481
returns server responses almost unparsed. As IMAP server responses can
5582
be quite complex this means everyone using imaplib ends up writing
56-
their own flimsy parsing routines which break easily.
83+
their own fragile parsing routines.
5784

5885
Also, imaplib doesn't make good use of exceptions. This means you need
5986
to check the return value of each call to imaplib to see if what you
@@ -76,39 +103,25 @@ IMAPClient's manual is available at http://imapclient.readthedocs.io/.
76103
Release notes can be found at
77104
http://imapclient.readthedocs.io/#release-history.
78105

79-
The Sphinx source for the documentation can be found under doc/src. If
80-
Sphinx is installed, the documentation can be rebuilt using::
81-
82-
python setup.py build_sphinx
83-
84-
See the imapclient/examples directory for examples of how to use
85-
IMAPClient. If the IMAPClient was installed from PyPI, the examples
86-
subdirectory can be found under the imapclient package in the
87-
installation directory.
106+
See the `examples` directory in the root of project source for
107+
examples of how to use IMAPClient.
88108

89109
Current Status
90110
--------------
91-
IMAPClient is currently under development but it is unlikely that
92-
the existing API will change in backwards-incompatible ways. Changes
93-
planned for the near future will only add extra functionality to the
94-
API.
95-
96111
You should feel confident using IMAPClient for production
97112
purposes. Any problems found will be fixed quickly once reported.
98113

114+
In order to clearly communicate version compatibility, IMAPClient
115+
will strictly adhere to the `Semantic Versioning <http://semver.org>`_
116+
scheme from version 1.0 onwards.
117+
99118
The project's home page is http://imapclient.freshfoo.com/ (this
100119
currently redirects to the IMAPClient Github site). Details about
101120
upcoming versions and planned features/fixes can be found in the issue
102-
tracker on Github. The maintainer also blogs about IMAPClient
121+
tracker on Github. The maintainers also blog about IMAPClient
103122
news. Those articles can be found `here
104123
<http://menno.io/tags/imapclient>`_.
105124

106-
Versions
107-
--------
108-
In order to clearly communicate version compatibility, IMAPClient
109-
will strictly adhere to the `Semantic Versioning <http://semver.org>`_
110-
scheme from version 1.0 onwards.
111-
112125
Mailing List
113126
------------
114127
The IMAPClient mailing list can be used to ask IMAPClient related
@@ -133,9 +146,8 @@ [email protected].
133146
Working on IMAPClient
134147
---------------------
135148
The `contributing documentation
136-
<http://imapclient.readthedocs.io/en/master/contributing.html>`_. contains
137-
information for those interested in improving IMAPClient and contributing back
138-
to the project.
149+
<http://imapclient.rtfd.io/en/master/contributing.html>`_ contains
150+
information for those interested in improving IMAPClient.
139151

140152
IMAP Servers
141153
------------
@@ -162,16 +174,14 @@ interact module like this::
162174

163175
"Live" Tests
164176
------------
165-
IMAPClient includes a series of functional tests which exercise
166-
it against a live IMAP account. It is useful for ensuring
177+
IMAPClient includes a series of live, functional tests which exercise
178+
it against a live IMAP account. These are useful for ensuring
167179
compatibility with a given IMAP server implementation.
168180

169-
The livetest functionality can also be accessed like this::
170-
171-
python -m imapclient.livetest <livetest.ini> [ optional unittest arguments ]
181+
The livetest functionality are run from the root of the project source
182+
like this::
172183

173-
Alternatively you can run the ``livetest.py`` script included with the
174-
source distribution. Use ``livetest.py --help`` to see usage.
184+
python livetest.py <livetest.ini> [ optional unittest arguments ]
175185

176186
The configuration file format is
177187
`described in the main documentation <http://imapclient.rtfd.io/#configuration-file-format>`_.

0 commit comments

Comments
 (0)