Skip to content

Commit

Permalink
fix query builder header list bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ikvk committed May 5, 2022
1 parent 26b1ae0 commit cc017e2
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
39 changes: 22 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
.. http://docutils.sourceforge.net/docs/user/rst/quickref.html
.. |nbsp| unicode:: 0xA0
:trim:

imap_tools 📧
=============

Work with email by IMAP:
High level lib for work with email by IMAP:

- Basic message operations: fetch, uids, numbers
- Parsed email message attributes
- Query builder for searching emails
- Query builder for search criteria
- Actions with emails: copy, delete, flag, move, append
- Actions with folders: list, set, get, create, exists, rename, subscribe, delete, status
- IDLE commands: start, poll, stop, wait
- Exceptions on failed operations
- No external dependencies
- No external dependencies, tested

.. image:: https://img.shields.io/pypi/dm/imap_tools.svg?style=social

=============== ===============================================================
=============== ================================================================================================
Python version 3.5+
License Apache-2.0
PyPI https://pypi.python.org/pypi/imap_tools/
RFC `IMAP4.1 <https://tools.ietf.org/html/rfc3501>`_, `EMAIL <https://tools.ietf.org/html/rfc3501>`_, `IMAP related RFCs <https://github.com/ikvk/imap_tools/blob/master/docs/IMAP_related_RFCs.txt>`_
=============== ===============================================================
RFC `IMAP4.1 <https://tools.ietf.org/html/rfc3501>`_,
`EMAIL <https://tools.ietf.org/html/rfc3501>`_,
`IMAP related RFCs <https://github.com/ikvk/imap_tools/blob/master/docs/IMAP_related_RFCs.txt>`_
=============== ================================================================================================

.. contents::

Expand Down Expand Up @@ -172,9 +177,9 @@ See `query examples <https://github.com/ikvk/imap_tools/blob/master/examples/sea
Search key table. Key types marked with `*` can accepts a sequence of values like list, tuple, set or generator.

============= =============== ====================== =================================================================
============= =============== ====================== ================================================================
Key Types Results Description
============= =============== ====================== =================================================================
============= =============== ====================== ================================================================
answered bool `ANSWERED/UNANSWERED` with/without the Answered flag
seen bool `SEEN/UNSEEN` with/without the Seen flag
flagged bool `FLAGGED/UNFLAGGED` with/without the Flagged flag
Expand Down Expand Up @@ -204,7 +209,7 @@ all True ALL all, criteria by default
uid iter(str)/str/U UID 1,2,17 corresponding to the specified unique identifier set
header H(str, str)* HEADER "A-Spam" "5.8" have a header that contains the specified str in the text
gmail_label str* X-GM-LABELS "label1" have this gmail label.
============= =============== ====================== =================================================================
============= =============== ====================== ================================================================

Server side search notes:

Expand Down Expand Up @@ -291,14 +296,14 @@ IDLE workflow

IDLE logic are in mailbox.idle manager, its methods are in the table below:

======== ============================================================================== ==========================
======== ============================================================================== ================================
Method Description Arguments
======== ============================================================================== ==========================
======== ============================================================================== ================================
start Switch on mailbox IDLE mode
poll Poll for IDLE responses timeout: Optional[float]
poll Poll for IDLE responses timeout: |nbsp| Optional[float]
stop Switch off mailbox IDLE mode
wait Switch on IDLE, poll responses, switch off IDLE on response, return responses timeout: Optional[float]
======== ============================================================================== ==========================
wait Switch on IDLE, poll responses, switch off IDLE on response, return responses timeout: |nbsp| Optional[float]
======== ============================================================================== ================================

.. code-block:: python
Expand Down Expand Up @@ -400,9 +405,9 @@ Big thanks to people who helped develop this library:
`RanjithNair1980 <https://github.com/RanjithNair1980>`_,
`NickC-NZ <https://github.com/NickC-NZ>`_,
`mweinelt <https://github.com/mweinelt>`_,
`lucbouge <https://github.com/lucbouge>`_
`lucbouge <https://github.com/lucbouge>`_,
`JacquelinCharbonnel <https://github.com/JacquelinCharbonnel>`_

Donate
------

💰 You may `donate <https://github.com/ikvk/imap_tools/blob/master/docs/donate.rst>`_, if this library helped you.
`✋ I want to help this library <https://github.com/ikvk/imap_tools/blob/master/docs/donate.rst>`_
18 changes: 4 additions & 14 deletions docs/donate.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
My PayPal 💰
| https://paypal.me/KaukinVK
| [email protected]
Thanks to all who donated 🎉
It is really nice.

Targeted fundraising 🎯
| 3k$ for create documentation. Style: https://alabaster.readthedocs.io/en/latest/
| Considering the dynamics - in ~100 years :D
| So you'd better buy strings for my balalaika and meat for my bear.
Do not forget to star imap_tools project ⭐
https://github.com/ikvk/imap_tools
1. If you find a bug or figure out how to improve the library - create an issue / merge request 🎯
2. If you haven't found any errors and haven't figured out how to improve, try to help other open projects that you use ✋
3. Star the project ⭐
4. If you have nowhere to put your money, spend it on your family, friends, loved ones, or people around you 💰
6 changes: 5 additions & 1 deletion docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
0.55.0
======
* Fixed query builder bug with key - "header" and value - [Header]

0.54.0
======
* EmailAddress full is property now, parse_email_addresses fixed
* Added MailBoxTls into __init__
* Added MailBoxTls into __init__.py
* Fixed tls.py example, rename examples, added basic.py example

0.53.0
Expand Down
2 changes: 1 addition & 1 deletion imap_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from .utils import EmailAddress
from .errors import *

__version__ = '0.54.0'
__version__ = '0.55.0'
5 changes: 4 additions & 1 deletion imap_tools/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self, name: str, value: str):
def __str__(self):
return '{0.name}: {0.value}'.format(self)

def __lt__(self, other):
return '{0.name}{0.value}'.format(self) < '{0.name}{0.value}'.format(other)


class UidRange:
"""
Expand Down Expand Up @@ -82,7 +85,7 @@ def __init__(
recent: Optional[bool] = None,
all: Optional[bool] = None, # noqa
uid: Optional[Union[str, Iterable[str], UidRange]] = None,
header: Optional[Header] = None,
header: Optional[Union[Header, List[Header]]] = None,
gmail_label: Optional[Union[str, List[str]]] = None): # todo newline after drop 3.5
self.converted_strings = converted_strings
for val in converted_strings:
Expand Down
1 change: 1 addition & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_converters(self):
self.assertEqual(A(all=True), '(ALL)')

self.assertEqual(A(header=H('X-Google-Smtp-Source', '123')), '(HEADER "X-Google-Smtp-Source" "123")')
self.assertEqual(A(header=[H('b', '1'), H('a', '2')]), '(HEADER "a" "2" HEADER "b" "1")')
self.assertEqual(A(uid='1,2'), '(UID 1,2)')
self.assertEqual(A(uid=['3', '4']), '(UID 3,4)')
self.assertEqual(A(uid=['3', '4:*']), '(UID 3,4:*)')
Expand Down

0 comments on commit cc017e2

Please sign in to comment.