From b204e19b81739ac8ddce980d396abcb9c0eb19ef Mon Sep 17 00:00:00 2001 From: Anshul Mittal Date: Wed, 13 May 2026 15:23:41 +0530 Subject: [PATCH 1/3] WIP: Multiple authors implementation and tests --- CHANGES.rst | 7 +- docs/api.rst | 3 + docs/guide.rst | 5 +- src/reader/__init__.py | 1 + src/reader/_app/legacy/templates/entry.html | 10 ++- src/reader/_app/templates/macros.html | 4 +- src/reader/_parser/feedparser.py | 72 +++++++++++++++++++- src/reader/_parser/jsonfeed.py | 49 ++++++------- src/reader/_plugins/legacy/enclosure_tags.py | 2 +- src/reader/_storage/_entries.py | 23 ++++++- src/reader/_storage/_feeds.py | 11 ++- src/reader/_storage/_schema.py | 39 ++++++++++- src/reader/_types.py | 32 +++++++-- src/reader/types.py | 68 +++++++++++++++--- tests/data/empty.atom.py | 1 + tests/data/full.atom.py | 7 +- tests/data/full.json.py | 7 +- tests/data/full.rss.py | 5 +- tests/data/invalid.json.py | 5 +- tests/test__types.py | 6 +- tests/test_parser.py | 70 +++++++++++++++++++ tests/test_reader.py | 23 ++++--- tests/test_reader_search.py | 5 +- tests/test_storage.py | 30 ++++++++ tests/test_types.py | 34 +++++++++ 25 files changed, 439 insertions(+), 80 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8fb228a5..4c8f4077 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,9 +14,14 @@ Unreleased * Add ``--json`` option to the ``list`` CLI commands. Thanks to `Puneet Dixit`_ for the PR. (:issue:`394`) - +* Add :attr:`~Entry.authors` (and corresponding attributes on feeds and sources) + to expose multiple authors and rich author data (name, email, URL). + The old ``author`` string attribute is deprecated. + Thanks to `Anshul Mittal`_ for the PR. + (:issue:`391`) .. _Puneet Dixit: https://github.com/puneetdixit200 +.. _Anshul Mittal: https://github.com/anderson688 Version 3.23 diff --git a/docs/api.rst b/docs/api.rst index 2e8b295a..7f5e14ba 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -28,6 +28,9 @@ Data objects .. autoclass:: Feed :members: +.. autoclass:: Author + :members: + .. autoclass:: ExceptionInfo :members: diff --git a/docs/guide.rst b/docs/guide.rst index 097a78bb..c1163302 100644 --- a/docs/guide.rst +++ b/docs/guide.rst @@ -374,7 +374,7 @@ As seen in the previous sections, updated=datetime.datetime(2020, 2, 28, 9, 34, 2, tzinfo=datetime.timezone.utc), title='Hello Internet', link='http://www.hellointernet.fm/', - author='CGP Grey', + authors=(Author(name='CGP Grey'),), subtitle='CGP Grey and Brady Haran talk about YouTube, life, work, whatever.', version='rss20', user_title=None, @@ -386,9 +386,10 @@ As seen in the previous sections, To get all the feeds, use the :meth:`~Reader.get_feeds` method:: >>> for feed in reader.get_feeds(): + ... authors = ", ".join(a.name for a in feed.authors if a.name) or 'unknown author' ... print( ... feed.title or feed.url, - ... f"by {feed.author or 'unknown author'},", + ... f"by {authors},", ... f"updated on {feed.updated or 'never'}", ... ) ... diff --git a/src/reader/__init__.py b/src/reader/__init__.py index 51e718ec..1fe2dafc 100644 --- a/src/reader/__init__.py +++ b/src/reader/__init__.py @@ -67,6 +67,7 @@ FeedToImport as FeedToImport, FeedImportResult as FeedImportResult, FeedExport as FeedExport, + Author as Author, ) from .exceptions import ( diff --git a/src/reader/_app/legacy/templates/entry.html b/src/reader/_app/legacy/templates/entry.html index 46df1694..7295aeda 100644 --- a/src/reader/_app/legacy/templates/entry.html +++ b/src/reader/_app/legacy/templates/entry.html @@ -18,7 +18,15 @@