Skip to main content

Parser for Bibdesk database files

Project description

BibDeskParser

Source code on Github PyPI Documentation Docs Tests Coverage MIT License

BibDeskParser reads and writes BibDesk .bib files exactly as BibDesk itself produces them: the header comment, linked files and URLs, @string macros, and static groups all round-trip byte-for-byte. The API centers on two classes: Library, a dict-like mapping of citation key to Entry, and Entry, a single bibliography record.

Development of BibDeskParser happens on Github.

You can read the full documentation online. See the page on BibDesk's .bib format for details on how BibDesk's special .bib features are handled, and the how-to guides for short recipes covering specific tasks.

Introduction

BibDesk is a bibliography manager for macOS that stores its database library as a standard BibTeX .bib file, but adds its own conventions on top of plain BibTeX -- tracking linked file attachments (macOS-specific), recording user-defined groups, custom support for @string macros and keyword fields, and more.

These extended features are stored in custom fields of individual entries, and in comments in the .bib file. A generic BibTeX library like BibtexParser is not aware of these BibDesk-specific features and thus provides no direct access to the stored data, and may even corrupt it on a round trip. BibDeskParser exists so you can read, script, and edit your BibDesk library directly in Python -- for batch edits, automation, or integration with other tools. It provides a simplified API on top of the BibtexParser library.

Making the bibliographic database accessible to AI coding agents is an explicit goal of the project: the bibdeskparser command-line tool mirrors the public Python API, so any agent that can run shell commands can inspect and edit a BibDesk library, with no dedicated integration and no server to keep running. See How to give an AI coding agent access to your library.

Installation

To install the latest released version of BibDeskParser:

pip install bibdeskparser

If you use uv, add BibDeskParser as a dependency of your project with

uv add bibdeskparser

or install the bibdeskparser command-line tool on your PATH, independently of any project, with

uv tool install bibdeskparser

Tip: If you use the command-line tool frequently, consider creating a shorter symlink for bibdeskparser, e.g. bib, so that you can write bib import 10.22331/q-2022-12-07-871.

To install the latest development version from Github:

pip install git+https://github.com/goerz/bibdeskparser.git@master#egg=bibdeskparser

Usage

>>> import tempfile
>>> from pathlib import Path
>>> from bibdeskparser import Entry, Library
>>> tmpdir = tempfile.TemporaryDirectory()
>>> bib_path = Path(tmpdir.name) / "references.bib"
>>> bib = Library()
>>> bib["Smith2020"] = Entry(
...     "article",
...     "Smith2020",
...     fields={
...         "title": "A Title",
...         "author": "Smith, John and Doe, Jane",
...         "journal": "J. Test",
...         "year": "2020",
...     },
... )
>>> bib.save(bib_path)

>>> bib = Library(bib_path)
>>> entry = bib["Smith2020"]
>>> print(entry["title"])
A Title
>>> print(entry.author[0].last[0])  # 'Smith'
Smith

>>> entry["title"] = "A Better Title"
>>> bib.groups["Favorites"] = ("Smith2020",)  # BibDesk static group
>>> entry.groups
('Favorites',)
>>> bib.save()
>>> tmpdir.cleanup()

Development

The project uses uv to manage the development environment and make as a task runner. After cloning the repository, run

make develop

to create a virtual environment with all development dependencies. Run make help for an overview of available targets, and see CONTRIBUTING.md for full contributing guidelines.

To put the bibdeskparser command-line tool on your PATH as an editable install that links back to your working copy — so changes to the source take effect without reinstalling — run

make install

Use make uninstall to remove it again.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bibdeskparser-0.2.1.tar.gz (126.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bibdeskparser-0.2.1-py3-none-any.whl (139.0 kB view details)

Uploaded Python 3

File details

Details for the file bibdeskparser-0.2.1.tar.gz.

File metadata

  • Download URL: bibdeskparser-0.2.1.tar.gz
  • Upload date:
  • Size: 126.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for bibdeskparser-0.2.1.tar.gz
Algorithm Hash digest
SHA256 66b5956462c0303915071a016d33e96ec3dd972d4e1ba133015367c819027663
MD5 4409dd93a9a48534a01c6d5726b94174
BLAKE2b-256 863b61d22526a0483daf9651a88471c671b4763f9eb9cc849c234017e61a4ea9

See more details on using hashes here.

File details

Details for the file bibdeskparser-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: bibdeskparser-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 139.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for bibdeskparser-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1cd32e2b81c4d8afb9070ea2c25bc7ca80053675a8b602605d3af785f9b26a0
MD5 9ddf11a34b576f776648ad38eb623387
BLAKE2b-256 0c4b29d2dbe146a2d725b0bc67fd4f22d75be2e3dfd55ce3c22a98a04c3ed5c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page