From 8ba460413d1a8defc467d082bead0bb17fc85009 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 2 Oct 2026 17:49:15 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=9D=20Show=20how=20to=20get=20v1-s?= =?UTF-8?q?tyle=20entry=20dicts=20in=20migration=20guide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/migrate.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/source/migrate.rst b/docs/source/migrate.rst index 9fc151b..03a19b5 100644 --- a/docs/source/migrate.rst +++ b/docs/source/migrate.rst @@ -88,6 +88,21 @@ While in v1 entries were represented as dicts, in v2 they are represented as ``E # ... but to facilitate migration or simple cases, this shorthand notation also works ... print(entry['title']) +If you need plain dicts as in v1 (e.g. to pass them on to another library), you can convert the entries: + +.. code-block:: python + + # v1 + entries = bib_database.entries + entries_dict = bib_database.entries_dict + + # v2 + entries = [dict(entry.items()) for entry in library.entries] + entries_dict = {key: dict(entry.items()) for key, entry in library.entries_dict.items()} + +As in v1, these dicts contain the ``ENTRYTYPE`` and ``ID`` keys. Field values are whatever the middleware produced +(e.g. a list of names after ``SeparateCoAuthors``), so they are not necessarily strings. + Similarly, other block types (comments, strings, ...) are now also represented as dedicated :ref:`object types `, but for them, the migration is straight forward and we will not go into detail here. From 91d3ab03d84bd95e0c9cee894b078bcc73c03035 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 2 Oct 2026 18:03:48 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Slim=20down=20entry-dict=20s?= =?UTF-8?q?nippet=20using=20dict(entry)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relies on Entry.keys()/__iter__ from #631. --- docs/source/migrate.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/source/migrate.rst b/docs/source/migrate.rst index 03a19b5..9595c27 100644 --- a/docs/source/migrate.rst +++ b/docs/source/migrate.rst @@ -88,7 +88,7 @@ While in v1 entries were represented as dicts, in v2 they are represented as ``E # ... but to facilitate migration or simple cases, this shorthand notation also works ... print(entry['title']) -If you need plain dicts as in v1 (e.g. to pass them on to another library), you can convert the entries: +If you need plain dicts as in v1, e.g. to pass entries on to another library, convert them: .. code-block:: python @@ -97,11 +97,10 @@ If you need plain dicts as in v1 (e.g. to pass them on to another library), you entries_dict = bib_database.entries_dict # v2 - entries = [dict(entry.items()) for entry in library.entries] - entries_dict = {key: dict(entry.items()) for key, entry in library.entries_dict.items()} + entries = [dict(entry) for entry in library.entries] + entries_dict = {entry["ID"]: entry for entry in entries} -As in v1, these dicts contain the ``ENTRYTYPE`` and ``ID`` keys. Field values are whatever the middleware produced -(e.g. a list of names after ``SeparateCoAuthors``), so they are not necessarily strings. +Field values are whatever the middleware produced (e.g. a list of names after ``SeparateCoAuthors``), not necessarily strings. Similarly, other block types (comments, strings, ...) are now also represented as dedicated :ref:`object types `,