bibdeskparser 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.3
2
+ Name: bibdeskparser
3
+ Version: 0.1.0
4
+ Summary: Parser for Bibdesk database files
5
+ Author: Michael Goerz
6
+ Author-email: Michael Goerz <mail@michaelgoerz.net>
7
+ License: MIT license
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Requires-Dist: bibtexparser==2.0.0b9
18
+ Requires-Dist: pyobjc-framework-cocoa ; sys_platform == 'darwin' and extra == 'macos'
19
+ Requires-Python: >=3.10
20
+ Project-URL: Homepage, https://github.com/goerz/bibdeskparser
21
+ Provides-Extra: macos
22
+ Description-Content-Type: text/markdown
23
+
24
+ # BibDeskParser
25
+
26
+ [![Source code on Github](https://img.shields.io/badge/goerz-bibdeskparser-blue.svg?logo=github)][Github]
27
+ [![PyPI](https://img.shields.io/pypi/v/bibdeskparser.svg)](https://pypi.python.org/pypi/bibdeskparser)
28
+ [![Documentation](https://img.shields.io/badge/docs-gh--pages-blue.svg)][docs]
29
+ [![Docs](https://github.com/goerz/bibdeskparser/actions/workflows/docs.yml/badge.svg?branch=master)](https://github.com/goerz/bibdeskparser/actions/workflows/docs.yml)
30
+ [![Tests](https://github.com/goerz/bibdeskparser/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/goerz/bibdeskparser/actions/workflows/test.yml)
31
+ [![Coverage](https://codecov.io/gh/goerz/bibdeskparser/branch/master/graph/badge.svg)](https://codecov.io/gh/goerz/bibdeskparser)
32
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
33
+
34
+ BibDeskParser reads and writes [BibDesk][]
35
+ `.bib` files exactly as BibDesk itself produces them: the header
36
+ comment, linked files and URLs, `@string` macros, and static groups all
37
+ round-trip byte-for-byte. The API centers on two classes: `Library`, a
38
+ dict-like mapping of citation key to `Entry`, and `Entry`, a single
39
+ bibliography record.
40
+
41
+ Development of BibDeskParser happens on [Github][].
42
+
43
+ You can read the full documentation [online][docs]. See the
44
+ [page on BibDesk's `.bib` format][bibdesk-format] for details on how
45
+ BibDesk's special `.bib` features are handled, and the
46
+ [how-to guides][howto] for short recipes covering specific tasks.
47
+
48
+ [docs]: https://goerz.github.io/bibdeskparser/
49
+ [bibdesk-format]: https://goerz.github.io/bibdeskparser/bibdesk_format.html
50
+ [howto]: https://goerz.github.io/bibdeskparser/howto.html
51
+
52
+ ## Introduction
53
+
54
+ [BibDesk][] is a bibliography manager for macOS that stores
55
+ its database library as a standard [BibTeX][] `.bib` file, but adds
56
+ its own conventions on top of plain BibTeX -- tracking linked
57
+ file attachments (macOS-specific), recording user-defined groups, custom
58
+ support for `@string` macros and keyword fields, and more.
59
+
60
+ These extended features are stored in custom fields of individual entries, and
61
+ in comments in the `.bib` file. A generic BibTeX library like [BibtexParser][]
62
+ is not aware of these BibDesk-specific features and thus provides no direct
63
+ access to the stored data, and may even corrupt it on a round trip.
64
+ BibDeskParser exists so you can read, script, and edit your BibDesk
65
+ library directly in Python -- for batch edits, automation, or
66
+ integration with other tools. It provides a simplified API on top
67
+ of the [BibtexParser][] library.
68
+
69
+
70
+ ## Installation
71
+
72
+ To install the latest released version of BibDeskParser:
73
+
74
+ ```
75
+ pip install bibdeskparser
76
+ ```
77
+
78
+ or, if you use [uv](https://docs.astral.sh/uv/):
79
+
80
+ ```
81
+ uv add bibdeskparser
82
+ ```
83
+
84
+
85
+ To install the latest development version from [Github][]:
86
+
87
+ ```
88
+ pip install git+https://github.com/goerz/bibdeskparser.git@master#egg=bibdeskparser
89
+ ```
90
+
91
+
92
+ ## Usage
93
+
94
+ ```python
95
+ >>> import tempfile
96
+ >>> from pathlib import Path
97
+ >>> from bibdeskparser import Entry, Library
98
+ >>> tmpdir = tempfile.TemporaryDirectory()
99
+ >>> bib_path = Path(tmpdir.name) / "references.bib"
100
+ >>> bib = Library()
101
+ >>> bib["Smith2020"] = Entry(
102
+ ... "article",
103
+ ... "Smith2020",
104
+ ... fields={
105
+ ... "title": "A Title",
106
+ ... "author": "Smith, John and Doe, Jane",
107
+ ... "journal": "J. Test",
108
+ ... "year": "2020",
109
+ ... },
110
+ ... )
111
+ >>> bib.save(bib_path)
112
+
113
+ >>> bib = Library(bib_path)
114
+ >>> entry = bib["Smith2020"]
115
+ >>> print(entry["title"])
116
+ A Title
117
+ >>> print(entry.author[0].last[0]) # 'Smith'
118
+ Smith
119
+
120
+ >>> entry["title"] = "A Better Title"
121
+ >>> bib.groups["Favorites"] = ("Smith2020",) # BibDesk static group
122
+ >>> entry.groups
123
+ ('Favorites',)
124
+ >>> bib.save()
125
+ >>> tmpdir.cleanup()
126
+
127
+ ```
128
+
129
+
130
+ ## Development
131
+
132
+ The project uses [uv](https://docs.astral.sh/uv/) to manage the development environment and [`make`](https://www.gnu.org/software/make/) as a task runner. After cloning the repository, run
133
+
134
+ ```
135
+ make develop
136
+ ```
137
+
138
+ 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.
139
+
140
+ [BibDesk]: https://bibdesk.sourceforge.io
141
+ [BibTeX]: https://en.wikipedia.org/wiki/BibTeX
142
+ [BibtexParser]: https://bibtexparser.readthedocs.io/en/main/
143
+ [Github]: https://github.com/goerz/bibdeskparser
144
+ [CONTRIBUTING.md]: https://github.com/goerz/bibdeskparser/blob/master/CONTRIBUTING.md
@@ -0,0 +1,121 @@
1
+ # BibDeskParser
2
+
3
+ [![Source code on Github](https://img.shields.io/badge/goerz-bibdeskparser-blue.svg?logo=github)][Github]
4
+ [![PyPI](https://img.shields.io/pypi/v/bibdeskparser.svg)](https://pypi.python.org/pypi/bibdeskparser)
5
+ [![Documentation](https://img.shields.io/badge/docs-gh--pages-blue.svg)][docs]
6
+ [![Docs](https://github.com/goerz/bibdeskparser/actions/workflows/docs.yml/badge.svg?branch=master)](https://github.com/goerz/bibdeskparser/actions/workflows/docs.yml)
7
+ [![Tests](https://github.com/goerz/bibdeskparser/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/goerz/bibdeskparser/actions/workflows/test.yml)
8
+ [![Coverage](https://codecov.io/gh/goerz/bibdeskparser/branch/master/graph/badge.svg)](https://codecov.io/gh/goerz/bibdeskparser)
9
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
10
+
11
+ BibDeskParser reads and writes [BibDesk][]
12
+ `.bib` files exactly as BibDesk itself produces them: the header
13
+ comment, linked files and URLs, `@string` macros, and static groups all
14
+ round-trip byte-for-byte. The API centers on two classes: `Library`, a
15
+ dict-like mapping of citation key to `Entry`, and `Entry`, a single
16
+ bibliography record.
17
+
18
+ Development of BibDeskParser happens on [Github][].
19
+
20
+ You can read the full documentation [online][docs]. See the
21
+ [page on BibDesk's `.bib` format][bibdesk-format] for details on how
22
+ BibDesk's special `.bib` features are handled, and the
23
+ [how-to guides][howto] for short recipes covering specific tasks.
24
+
25
+ [docs]: https://goerz.github.io/bibdeskparser/
26
+ [bibdesk-format]: https://goerz.github.io/bibdeskparser/bibdesk_format.html
27
+ [howto]: https://goerz.github.io/bibdeskparser/howto.html
28
+
29
+ ## Introduction
30
+
31
+ [BibDesk][] is a bibliography manager for macOS that stores
32
+ its database library as a standard [BibTeX][] `.bib` file, but adds
33
+ its own conventions on top of plain BibTeX -- tracking linked
34
+ file attachments (macOS-specific), recording user-defined groups, custom
35
+ support for `@string` macros and keyword fields, and more.
36
+
37
+ These extended features are stored in custom fields of individual entries, and
38
+ in comments in the `.bib` file. A generic BibTeX library like [BibtexParser][]
39
+ is not aware of these BibDesk-specific features and thus provides no direct
40
+ access to the stored data, and may even corrupt it on a round trip.
41
+ BibDeskParser exists so you can read, script, and edit your BibDesk
42
+ library directly in Python -- for batch edits, automation, or
43
+ integration with other tools. It provides a simplified API on top
44
+ of the [BibtexParser][] library.
45
+
46
+
47
+ ## Installation
48
+
49
+ To install the latest released version of BibDeskParser:
50
+
51
+ ```
52
+ pip install bibdeskparser
53
+ ```
54
+
55
+ or, if you use [uv](https://docs.astral.sh/uv/):
56
+
57
+ ```
58
+ uv add bibdeskparser
59
+ ```
60
+
61
+
62
+ To install the latest development version from [Github][]:
63
+
64
+ ```
65
+ pip install git+https://github.com/goerz/bibdeskparser.git@master#egg=bibdeskparser
66
+ ```
67
+
68
+
69
+ ## Usage
70
+
71
+ ```python
72
+ >>> import tempfile
73
+ >>> from pathlib import Path
74
+ >>> from bibdeskparser import Entry, Library
75
+ >>> tmpdir = tempfile.TemporaryDirectory()
76
+ >>> bib_path = Path(tmpdir.name) / "references.bib"
77
+ >>> bib = Library()
78
+ >>> bib["Smith2020"] = Entry(
79
+ ... "article",
80
+ ... "Smith2020",
81
+ ... fields={
82
+ ... "title": "A Title",
83
+ ... "author": "Smith, John and Doe, Jane",
84
+ ... "journal": "J. Test",
85
+ ... "year": "2020",
86
+ ... },
87
+ ... )
88
+ >>> bib.save(bib_path)
89
+
90
+ >>> bib = Library(bib_path)
91
+ >>> entry = bib["Smith2020"]
92
+ >>> print(entry["title"])
93
+ A Title
94
+ >>> print(entry.author[0].last[0]) # 'Smith'
95
+ Smith
96
+
97
+ >>> entry["title"] = "A Better Title"
98
+ >>> bib.groups["Favorites"] = ("Smith2020",) # BibDesk static group
99
+ >>> entry.groups
100
+ ('Favorites',)
101
+ >>> bib.save()
102
+ >>> tmpdir.cleanup()
103
+
104
+ ```
105
+
106
+
107
+ ## Development
108
+
109
+ The project uses [uv](https://docs.astral.sh/uv/) to manage the development environment and [`make`](https://www.gnu.org/software/make/) as a task runner. After cloning the repository, run
110
+
111
+ ```
112
+ make develop
113
+ ```
114
+
115
+ 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.
116
+
117
+ [BibDesk]: https://bibdesk.sourceforge.io
118
+ [BibTeX]: https://en.wikipedia.org/wiki/BibTeX
119
+ [BibtexParser]: https://bibtexparser.readthedocs.io/en/main/
120
+ [Github]: https://github.com/goerz/bibdeskparser
121
+ [CONTRIBUTING.md]: https://github.com/goerz/bibdeskparser/blob/master/CONTRIBUTING.md
@@ -0,0 +1,149 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.9,<0.12"]
3
+ build-backend = "uv_build"
4
+
5
+ [project]
6
+ name = "bibdeskparser"
7
+ version = "0.1.0"
8
+ description = "Parser for Bibdesk database files"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT license" }
12
+ authors = [
13
+ { name = "Michael Goerz", email = "mail@michaelgoerz.net" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Natural Language :: English",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ ]
26
+ dependencies = ["bibtexparser==2.0.0b9"]
27
+
28
+ [project.optional-dependencies]
29
+ macos = ["pyobjc-framework-Cocoa; sys_platform == 'darwin'"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/goerz/bibdeskparser"
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pytest>=7",
37
+ "pytest-cov>=4",
38
+ "pytest-xdist>=3",
39
+ "packaging>=21",
40
+ "coverage>=7",
41
+ "coveralls>=3",
42
+ "ipdb>=0.13",
43
+ "ipython>=8",
44
+ ]
45
+ docs = [
46
+ "sphinx>=7",
47
+ "sphinx_rtd_theme>=2",
48
+ "sphinx-copybutton>=0.5",
49
+ "sphinx-autobuild>=2024.2",
50
+ "myst-parser>=2",
51
+ "docs-versions-menu>=0.6",
52
+ "gitpython>=3",
53
+ "sphinx-autodoc2>=0.5",
54
+ ]
55
+ lint = [
56
+ "black>=24",
57
+ "isort>=5",
58
+ "flake8>=6",
59
+ "flake8-pyproject>=1",
60
+ "pylint>=3",
61
+ "pre-commit>=3.5",
62
+ ]
63
+ release = [
64
+ "click>=8",
65
+ "gitpython>=3",
66
+ "packaging>=21",
67
+ "pytest>=7",
68
+ ]
69
+
70
+ [tool.black]
71
+ line-length = 79
72
+
73
+ [tool.isort]
74
+ known_first_party = ["bibdeskparser"]
75
+ force_single_line = false
76
+ lines_after_imports = -1
77
+ line_length = 79
78
+ use_parentheses = true
79
+ multi_line_output = 3
80
+ include_trailing_comma = true
81
+ skip_glob = ["src/*/__init__.py"]
82
+
83
+ [tool.flake8]
84
+ exclude = ["docs"]
85
+ max-line-length = 79
86
+ extend-ignore = [
87
+ # See https://github.com/PyCQA/pycodestyle/issues/373
88
+ "E203",
89
+ # don't care about "ambiguous variable names"
90
+ "E741",
91
+ # when I use lambdas, I know what I'm doing
92
+ "E731",
93
+ ]
94
+
95
+ [tool.pytest.ini_options]
96
+ # tests/Refs contains test data and standalone helper scripts, not tests
97
+ addopts = "-ra --ignore=tests/Refs"
98
+
99
+ [tool.coverage.run]
100
+ relative_files = true
101
+ source = ["bibdeskparser"]
102
+
103
+ [tool.pylint."messages control"]
104
+ disable = [
105
+ "invalid-name",
106
+ "unidiomatic-typecheck",
107
+ "consider-iterating-dictionary",
108
+ "consider-using-enumerate",
109
+ "too-many-lines",
110
+ "multiple-statements",
111
+ "wrong-spelling-in-comment",
112
+ "wrong-spelling-in-docstring",
113
+ "len-as-condition",
114
+ "import-error",
115
+ "too-many-function-args",
116
+ "assignment-from-none",
117
+ "too-many-instance-attributes",
118
+ "too-few-public-methods",
119
+ "too-many-public-methods",
120
+ "too-many-return-statements",
121
+ "too-many-branches",
122
+ "too-many-arguments",
123
+ "too-many-locals",
124
+ "too-many-statements",
125
+ "too-many-boolean-expressions",
126
+ "too-many-nested-blocks",
127
+ "exec-used",
128
+ "eval-used",
129
+ "using-constant-test",
130
+ "protected-access",
131
+ "global-statement",
132
+ "unused-argument",
133
+ "no-else-return",
134
+ "ungrouped-imports",
135
+ "unnecessary-lambda",
136
+ ]
137
+
138
+ [tool.pylint.format]
139
+ max-line-length = 79
140
+
141
+ [tool.pylint.design]
142
+ max-args = 10
143
+ max-attributes = 15
144
+ max-bool-expr = 10
145
+ max-branches = 20
146
+ max-locals = 30
147
+ max-returns = 10
148
+ max-statements = 200
149
+ max-public-methods = 40
@@ -0,0 +1,23 @@
1
+ """Parser for [BibDesk](https://bibdesk.sourceforge.io) `.bib` files.
2
+
3
+ This package builds on [bibtexparser](
4
+ https://bibtexparser.readthedocs.io/en/main/) to read and write BibTeX
5
+ databases as maintained by the BibDesk application.
6
+ """
7
+
8
+ from importlib.metadata import version
9
+
10
+ from .entry import Entry, Value
11
+ from .library import Library, StaleFileError
12
+
13
+ __version__ = version("bibdeskparser")
14
+
15
+ # All members whose name does not start with an underscore must be listed
16
+ # either in __all__ or in __private__
17
+ __all__ = [
18
+ "Library",
19
+ "Entry",
20
+ "Value",
21
+ "StaleFileError",
22
+ ]
23
+ __private__ = []