Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
v0.3.0 (in development)
v0.2.3 (in development)
-----------------------
- Remove unused `typing_extensions` dependency
- Support Python 3.14
- Drop support for Python 3.8 and 3.9
- `email2dict()`:
- Omit the `Date` header if the date cannot be parsed
- Omit the `Resent-Date` header if no dates can be parsed

v0.2.2 (2024-12-01)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/mailbits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Visit <https://github.com/jwodder/mailbits> for more information.
"""

__version__ = "0.3.0.dev1"
__version__ = "0.2.3.dev1"
__author__ = "John Thorvald Wodder II"
__author_email__ = "mailbits@varonathe.org"
__license__ = "MIT"
Expand Down
8 changes: 5 additions & 3 deletions src/mailbits/email2dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ def process_date_headers(dh: list[Any]) -> list[datetime]:
data = []
for h in dh:
assert isinstance(h, hr.DateHeader)
data.append(h.datetime)
if (dt := h.datetime) is not None:
data.append(dt)
return data


def process_unique_date_header(dh: list[Any]) -> datetime:
def process_unique_date_header(dh: list[Any]) -> datetime | None:
assert len(dh) == 1
assert isinstance(dh[0], hr.UniqueDateHeader)
return dh[0].datetime
Expand Down Expand Up @@ -184,7 +185,8 @@ def email2dict(msg: Message, include_all: bool = False) -> MessageDict:
if takes_argument(processor, "include_all"):
kwargs["include_all"] = include_all
v = processor(values, **kwargs)
data["headers"][header] = v
if v is not None and v != []:
data["headers"][header] = v
data["preamble"] = msg.preamble
if msg.get_content_maintype() == "message":
# Some "message/*" subtypes (specifically, as of Python 3.9, rfc822 and
Expand Down