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, and set up a config file, with a default_bib_file 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

Library loads an existing .bib file and behaves like a dict of citation key to Entry. The examples below use the example database shipped in this repository at tests/Refs/refs.bib; substitute the path to your own library.

>>> from bibdeskparser import Library
>>> bib = Library("tests/Refs/refs.bib")
>>> len(bib)
61
>>> entry = bib["GoerzQ2022"]
>>> print(entry["title"])
Quantum Optimal Control via Semi-Automatic Differentiation
>>> print(entry.author[0].last[0])
Goerz
>>> entry.files  # linked PDF attachment, relative to the .bib file
['GoerzQ2022.pdf']

Full-text search and rendering a formatted citation:

>>> [e.key for e in bib.search("tractor atom interferometry")]
['RaithelQST2022']
>>> print(bib.render("RaithelQST2022"))
G. Raithel, A. Duspayev, B. Dash, *et al.* *Principles of tractor atom interferometry*. [Quantum Sci. Technol. **8**, p. 014001](https://doi.org/10.1088/2058-9565/ac9429) (2022), [arXiv:2207.09023](https://arxiv.org/abs/2207.09023).

Any change is written back with save(), preserving BibDesk's file format byte-for-byte for everything that was not touched:

>>> entry["note"] = "Implemented in the QuantumControl.jl framework."
>>> bib.groups["To Read"] = ("BrifNJP2010", "KochEPJQT2022")
>>> bib["KochEPJQT2022"].groups
('To Read',)
>>> bib.save()

A new .bib file can also be created from scratch, with Library() in Python or bibdeskparser create on the command line.

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.3.0.tar.gz (153.9 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.3.0-py3-none-any.whl (168.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bibdeskparser-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6fa03e2b5f5cbc374d58ecd9ad2f331ad11c66d54ba03823afb50f7d8e6bd82b
MD5 2e378417f64e604ffe1488e8d4577d75
BLAKE2b-256 993695dcf5b42bda4986419a39b19e20a092a6d773362d7eefaa5176ba2e3d60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bibdeskparser-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 168.4 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b299812362f4ff3e0353941a71e6cc9cc9166a8be8819590747405b24d7d3db9
MD5 6fded7da60a0c921a95963f04ba3e9fa
BLAKE2b-256 9a1390c5db2c197f0bba61dc0e7bfb380c396b7413daa5da3092264bee494e86

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