bibliography-io 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.
- bibliography_io-0.1.0/.github/workflows/ci.yml +80 -0
- bibliography_io-0.1.0/.github/workflows/docs.yml +43 -0
- bibliography_io-0.1.0/.github/workflows/publish.yml +40 -0
- bibliography_io-0.1.0/.gitignore +8 -0
- bibliography_io-0.1.0/.pre-commit-config.yaml +18 -0
- bibliography_io-0.1.0/LICENSE +21 -0
- bibliography_io-0.1.0/PKG-INFO +139 -0
- bibliography_io-0.1.0/README.md +97 -0
- bibliography_io-0.1.0/RELEASING.md +75 -0
- bibliography_io-0.1.0/docs/Makefile +14 -0
- bibliography_io-0.1.0/docs/api.rst +21 -0
- bibliography_io-0.1.0/docs/conf.py +23 -0
- bibliography_io-0.1.0/docs/index.rst +47 -0
- bibliography_io-0.1.0/docs/make.bat +21 -0
- bibliography_io-0.1.0/docs/usage.rst +67 -0
- bibliography_io-0.1.0/pyproject.toml +59 -0
- bibliography_io-0.1.0/src/bibliography_io/__init__.py +247 -0
- bibliography_io-0.1.0/src/bibliography_io/constants.py +104 -0
- bibliography_io-0.1.0/src/bibliography_io/core.py +597 -0
- bibliography_io-0.1.0/src/bibliography_io/exceptions.py +37 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/__init__.py +4 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/bib.py +383 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/enl.py +113 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/json.py +57 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/load_utils.py +311 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/load_utils_formatter.py +180 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/load_utils_name_formatter.py +145 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/loader.py +129 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/md.py +93 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/nbib.py +113 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/ris.py +256 -0
- bibliography_io-0.1.0/src/bibliography_io/loader/table.py +75 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/__init__.py +4 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/bib.py +146 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/csv.py +66 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/excel.py +75 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/markdown.py +92 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/ris.py +114 -0
- bibliography_io-0.1.0/src/bibliography_io/writer/write_utils.py +72 -0
- bibliography_io-0.1.0/tests/data/bib/load.bib +60 -0
- bibliography_io-0.1.0/tests/data/bib/load_expected.bib +51 -0
- bibliography_io-0.1.0/tests/data/bib/write_expected.bib +7 -0
- bibliography_io-0.1.0/tests/data/bib/write_expected.ris +8 -0
- bibliography_io-0.1.0/tests/data/csv/load.csv +3 -0
- bibliography_io-0.1.0/tests/data/csv/load_expected.bib +43 -0
- bibliography_io-0.1.0/tests/data/csv/write_expected.bib +5 -0
- bibliography_io-0.1.0/tests/data/csv/write_expected.csv +2 -0
- bibliography_io-0.1.0/tests/data/enl/load.enl +36 -0
- bibliography_io-0.1.0/tests/data/enl/load_expected.bib +13 -0
- bibliography_io-0.1.0/tests/data/md/load.md +6 -0
- bibliography_io-0.1.0/tests/data/nbib/load.nbib +22 -0
- bibliography_io-0.1.0/tests/data/nbib/load_expected.bib +20 -0
- bibliography_io-0.1.0/tests/data/ris/load.ris +45 -0
- bibliography_io-0.1.0/tests/data/ris/load_expected.bib +14 -0
- bibliography_io-0.1.0/tests/data/ris/nestedknowledge_numbered_records.ris +54 -0
- bibliography_io-0.1.0/tests/data/ris/write_expected.bib +7 -0
- bibliography_io-0.1.0/tests/data/ris/write_expected.ris +8 -0
- bibliography_io-0.1.0/tests/data/xlsx/load.xlsx +0 -0
- bibliography_io-0.1.0/tests/data/xlsx/load_expected.bib +48 -0
- bibliography_io-0.1.0/tests/data/xlsx/write_expected.bib +2 -0
- bibliography_io-0.1.0/tests/data/xlsx/write_expected.xlsx +0 -0
- bibliography_io-0.1.0/tests/test_bib.py +70 -0
- bibliography_io-0.1.0/tests/test_constants.py +24 -0
- bibliography_io-0.1.0/tests/test_csv.py +50 -0
- bibliography_io-0.1.0/tests/test_enl.py +54 -0
- bibliography_io-0.1.0/tests/test_md.py +28 -0
- bibliography_io-0.1.0/tests/test_nbib.py +30 -0
- bibliography_io-0.1.0/tests/test_public_api.py +68 -0
- bibliography_io-0.1.0/tests/test_ris.py +76 -0
- bibliography_io-0.1.0/tests/test_xlsx.py +36 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
hooks:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: python -m pip install --upgrade pip pre-commit
|
|
19
|
+
- run: pre-commit run --all-files
|
|
20
|
+
|
|
21
|
+
core-tests:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
- run: python -m pip install --upgrade pip
|
|
33
|
+
- run: python -m pip install -e ".[test]"
|
|
34
|
+
- run: pytest
|
|
35
|
+
|
|
36
|
+
build-and-wheel-smoke:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.12"
|
|
43
|
+
- run: python -m pip install --upgrade pip build twine
|
|
44
|
+
- run: python -m build
|
|
45
|
+
- run: python -m twine check dist/*
|
|
46
|
+
- run: python -m venv /tmp/bibliography-io-wheel-venv
|
|
47
|
+
- run: /tmp/bibliography-io-wheel-venv/bin/python -m pip install dist/*.whl
|
|
48
|
+
- name: Smoke-test installed wheel without optional backends
|
|
49
|
+
working-directory: /tmp
|
|
50
|
+
run: |
|
|
51
|
+
/tmp/bibliography-io-wheel-venv/bin/python - <<'PY'
|
|
52
|
+
import importlib.util
|
|
53
|
+
from importlib.metadata import entry_points
|
|
54
|
+
from pathlib import Path
|
|
55
|
+
from tempfile import TemporaryDirectory
|
|
56
|
+
|
|
57
|
+
import bibliography_io
|
|
58
|
+
from bibliography_io.exceptions import OptionalBackendUnavailableError
|
|
59
|
+
|
|
60
|
+
assert importlib.util.find_spec("colrev") is None
|
|
61
|
+
assert not entry_points().select(
|
|
62
|
+
group="bibliography_io.backends", name="markdown"
|
|
63
|
+
)
|
|
64
|
+
records = bibliography_io.loads(
|
|
65
|
+
"@article{wheel_smoke, title={Installed wheel}}", format="bib"
|
|
66
|
+
)
|
|
67
|
+
assert records["wheel_smoke"]["title"] == "Installed wheel"
|
|
68
|
+
with TemporaryDirectory() as directory:
|
|
69
|
+
path = Path(directory) / "smoke.bib"
|
|
70
|
+
bibliography_io.write_records(records, path)
|
|
71
|
+
assert bibliography_io.load_records(path) == records
|
|
72
|
+
markdown = Path(directory) / "references.md"
|
|
73
|
+
markdown.write_text("# References\n\nA reference", encoding="utf-8")
|
|
74
|
+
try:
|
|
75
|
+
bibliography_io.load_records(markdown)
|
|
76
|
+
except OptionalBackendUnavailableError:
|
|
77
|
+
pass
|
|
78
|
+
else:
|
|
79
|
+
raise AssertionError("Markdown backend should not be installed")
|
|
80
|
+
PY
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: pages-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
- run: python -m pip install --upgrade pip
|
|
24
|
+
- run: python -m pip install -e ".[docs]"
|
|
25
|
+
- run: python -m sphinx -W --keep-going -b html docs docs/_build/html
|
|
26
|
+
- uses: actions/upload-pages-artifact@v3
|
|
27
|
+
with:
|
|
28
|
+
path: docs/_build/html
|
|
29
|
+
|
|
30
|
+
deploy:
|
|
31
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
32
|
+
needs: build
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
environment:
|
|
35
|
+
name: github-pages
|
|
36
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write
|
|
39
|
+
pages: write
|
|
40
|
+
steps:
|
|
41
|
+
- name: Deploy to GitHub Pages
|
|
42
|
+
id: deployment
|
|
43
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: python -m pip install --upgrade pip build twine
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- run: python -m twine check dist/*
|
|
21
|
+
- uses: actions/upload-artifact@v4
|
|
22
|
+
with:
|
|
23
|
+
name: python-package-distributions
|
|
24
|
+
path: dist/
|
|
25
|
+
|
|
26
|
+
publish:
|
|
27
|
+
needs: build
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
environment:
|
|
30
|
+
name: pypi
|
|
31
|
+
url: https://pypi.org/p/bibliography-io
|
|
32
|
+
permissions:
|
|
33
|
+
id-token: write
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/download-artifact@v4
|
|
36
|
+
with:
|
|
37
|
+
name: python-package-distributions
|
|
38
|
+
path: dist/
|
|
39
|
+
# Configure this workflow as a trusted publisher in the PyPI project settings.
|
|
40
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v5.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
exclude: ^tests/.*/data/
|
|
7
|
+
- id: end-of-file-fixer
|
|
8
|
+
exclude: ^tests/.*/data/
|
|
9
|
+
- id: check-yaml
|
|
10
|
+
- id: check-toml
|
|
11
|
+
- id: check-merge-conflict
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.11.13
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff
|
|
17
|
+
args: [--fix]
|
|
18
|
+
- id: ruff-format
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Gerit Wagner and Julian Prester
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bibliography-io
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Loading and writing bibliographic records across formats
|
|
5
|
+
Project-URL: Homepage, https://github.com/CoLRev-Environment/bibliography-io
|
|
6
|
+
Project-URL: Repository, https://github.com/CoLRev-Environment/bibliography-io
|
|
7
|
+
Project-URL: Issues, https://github.com/CoLRev-Environment/bibliography-io/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/CoLRev-Environment/bibliography-io/releases
|
|
9
|
+
Project-URL: Documentation, https://colrev-environment.github.io/bibliography-io/
|
|
10
|
+
Author: Gerit Wagner
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Text Processing
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: openpyxl>=3.1.2
|
|
26
|
+
Requires-Dist: pandas<3,>=2.2
|
|
27
|
+
Requires-Dist: xlrd>=2.0.1
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: colrev; extra == 'all'
|
|
30
|
+
Requires-Dist: requests>=2.31; extra == 'all'
|
|
31
|
+
Provides-Extra: colrev
|
|
32
|
+
Requires-Dist: colrev; extra == 'colrev'
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: sphinx-copybutton>=0.5.2; extra == 'docs'
|
|
35
|
+
Requires-Dist: sphinx-rtd-theme>=3.0; extra == 'docs'
|
|
36
|
+
Requires-Dist: sphinx<9,>=7.3; extra == 'docs'
|
|
37
|
+
Provides-Extra: requests
|
|
38
|
+
Requires-Dist: requests>=2.31; extra == 'requests'
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
<div align="center">
|
|
44
|
+
|
|
45
|
+
# bibliography-io
|
|
46
|
+
|
|
47
|
+
[](https://pypi.org/project/bibliography-io/)
|
|
48
|
+

|
|
49
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/blob/main/LICENSE)
|
|
50
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/actions/workflows/ci.yml)
|
|
51
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/actions/workflows/docs.yml)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
`bibliography-io` provides standalone loading and writing of bibliographic
|
|
56
|
+
records. Its core API does not require CoLRev or GROBID.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
Install the base package with:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
pip install bibliography-io
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The optional `colrev` extra is for legacy compatibility modules. It is not
|
|
67
|
+
needed by the core file and string APIs. Markdown reference-list parsing has no
|
|
68
|
+
released optional backend yet.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from bibliography_io import load_records, write_records
|
|
74
|
+
|
|
75
|
+
records = load_records("references.bib")
|
|
76
|
+
write_records(records, "references.ris")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
File APIs infer the format from recognized suffixes; an explicit `format` can
|
|
80
|
+
override inference. String APIs always require `format`:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from bibliography_io import dumps, loads
|
|
84
|
+
|
|
85
|
+
records = loads("@article{example, title={An example}}", format="bib")
|
|
86
|
+
text = dumps(records, format="bib")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Format support
|
|
90
|
+
|
|
91
|
+
| Format | Read files | Write files | String APIs |
|
|
92
|
+
| --- | --- | --- | --- |
|
|
93
|
+
| BibTeX | Yes | Yes | `loads` / `dumps` |
|
|
94
|
+
| RIS | Yes | Yes | `loads` / `dumps` |
|
|
95
|
+
| CSV | Yes | Yes | `loads` / `dumps` |
|
|
96
|
+
| Excel | `.xls`, `.xlsx` | `.xlsx` | File APIs only |
|
|
97
|
+
| ENL / EndNote | `.enl`, `.txt` | No | `loads` only |
|
|
98
|
+
| NBIB | Yes | No | `loads` only |
|
|
99
|
+
| JSON | Yes | No | `loads` only |
|
|
100
|
+
| Markdown table | No | Yes | `dumps` |
|
|
101
|
+
| Markdown reference list | Pending optional backend | No | Pending optional backend |
|
|
102
|
+
|
|
103
|
+
Markdown table serialization is built into the core. Markdown reference-list
|
|
104
|
+
parsing is a separate optional feature; its backend and installation extra are
|
|
105
|
+
not finalized. Requesting Markdown input without a registered backend raises
|
|
106
|
+
``OptionalBackendUnavailableError``.
|
|
107
|
+
|
|
108
|
+
Historical root aliases (``load``, ``write``, ``write_file``, ``to_string``,
|
|
109
|
+
``load_df``, and ``get_nr_records``) are deprecated immediately and will be
|
|
110
|
+
removed in a future release.
|
|
111
|
+
|
|
112
|
+
See the [documentation](https://colrev-environment.github.io/bibliography-io/)
|
|
113
|
+
for installation details, usage examples, and the generated API reference.
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
Install the package's test extra and run the standalone test suite. The tests
|
|
118
|
+
use the package API and do not require CoLRev:
|
|
119
|
+
|
|
120
|
+
```shell
|
|
121
|
+
pip install -e ".[test]"
|
|
122
|
+
pip install build pre-commit
|
|
123
|
+
pre-commit install
|
|
124
|
+
pre-commit run --all-files
|
|
125
|
+
pytest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Build the documentation locally with:
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
pip install -e ".[docs]"
|
|
132
|
+
python -m sphinx -W --keep-going -b html docs docs/_build/html
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
See [RELEASING.md](RELEASING.md) for the package build and publication process.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
This project is distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# bibliography-io
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/bibliography-io/)
|
|
6
|
+

|
|
7
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/actions/workflows/ci.yml)
|
|
9
|
+
[](https://github.com/CoLRev-Environment/bibliography-io/actions/workflows/docs.yml)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
`bibliography-io` provides standalone loading and writing of bibliographic
|
|
14
|
+
records. Its core API does not require CoLRev or GROBID.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Install the base package with:
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
pip install bibliography-io
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The optional `colrev` extra is for legacy compatibility modules. It is not
|
|
25
|
+
needed by the core file and string APIs. Markdown reference-list parsing has no
|
|
26
|
+
released optional backend yet.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from bibliography_io import load_records, write_records
|
|
32
|
+
|
|
33
|
+
records = load_records("references.bib")
|
|
34
|
+
write_records(records, "references.ris")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
File APIs infer the format from recognized suffixes; an explicit `format` can
|
|
38
|
+
override inference. String APIs always require `format`:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from bibliography_io import dumps, loads
|
|
42
|
+
|
|
43
|
+
records = loads("@article{example, title={An example}}", format="bib")
|
|
44
|
+
text = dumps(records, format="bib")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Format support
|
|
48
|
+
|
|
49
|
+
| Format | Read files | Write files | String APIs |
|
|
50
|
+
| --- | --- | --- | --- |
|
|
51
|
+
| BibTeX | Yes | Yes | `loads` / `dumps` |
|
|
52
|
+
| RIS | Yes | Yes | `loads` / `dumps` |
|
|
53
|
+
| CSV | Yes | Yes | `loads` / `dumps` |
|
|
54
|
+
| Excel | `.xls`, `.xlsx` | `.xlsx` | File APIs only |
|
|
55
|
+
| ENL / EndNote | `.enl`, `.txt` | No | `loads` only |
|
|
56
|
+
| NBIB | Yes | No | `loads` only |
|
|
57
|
+
| JSON | Yes | No | `loads` only |
|
|
58
|
+
| Markdown table | No | Yes | `dumps` |
|
|
59
|
+
| Markdown reference list | Pending optional backend | No | Pending optional backend |
|
|
60
|
+
|
|
61
|
+
Markdown table serialization is built into the core. Markdown reference-list
|
|
62
|
+
parsing is a separate optional feature; its backend and installation extra are
|
|
63
|
+
not finalized. Requesting Markdown input without a registered backend raises
|
|
64
|
+
``OptionalBackendUnavailableError``.
|
|
65
|
+
|
|
66
|
+
Historical root aliases (``load``, ``write``, ``write_file``, ``to_string``,
|
|
67
|
+
``load_df``, and ``get_nr_records``) are deprecated immediately and will be
|
|
68
|
+
removed in a future release.
|
|
69
|
+
|
|
70
|
+
See the [documentation](https://colrev-environment.github.io/bibliography-io/)
|
|
71
|
+
for installation details, usage examples, and the generated API reference.
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
Install the package's test extra and run the standalone test suite. The tests
|
|
76
|
+
use the package API and do not require CoLRev:
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
pip install -e ".[test]"
|
|
80
|
+
pip install build pre-commit
|
|
81
|
+
pre-commit install
|
|
82
|
+
pre-commit run --all-files
|
|
83
|
+
pytest
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Build the documentation locally with:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
pip install -e ".[docs]"
|
|
90
|
+
python -m sphinx -W --keep-going -b html docs docs/_build/html
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
See [RELEASING.md](RELEASING.md) for the package build and publication process.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
This project is distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
The initial release version proposed for this project is `0.1.0`. Confirm the
|
|
4
|
+
version and package name with the maintainers before publishing.
|
|
5
|
+
|
|
6
|
+
## Required pre-release checks
|
|
7
|
+
|
|
8
|
+
1. Ensure the CI test job passes for the supported Python versions. It installs
|
|
9
|
+
`bibliography-io` and its test extra without CoLRev or GROBID, then runs the
|
|
10
|
+
complete standalone test suite:
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
python -m pip install -e ".[test]"
|
|
14
|
+
pytest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The test suite exercises the public bibliography-io API and repository data
|
|
18
|
+
fixtures without importing CoLRev.
|
|
19
|
+
2. Build and validate the release artifacts, then install the wheel into a clean
|
|
20
|
+
environment without optional extras:
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
python -m pip install --upgrade build twine
|
|
24
|
+
python -m build
|
|
25
|
+
python -m twine check dist/*
|
|
26
|
+
python -m venv /tmp/bibliography-io-wheel-smoke
|
|
27
|
+
/tmp/bibliography-io-wheel-smoke/bin/python -m pip install dist/*.whl
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
From outside the source checkout, smoke-test imports and a BibTeX file
|
|
31
|
+
round-trip with the installed wheel. The wheel test must not install the
|
|
32
|
+
`colrev`, `requests`, or Markdown backend extras.
|
|
33
|
+
3. Markdown table output is part of core testing. Markdown reference-list
|
|
34
|
+
parsing is pending an optional backend; test it separately after the backend
|
|
35
|
+
package, entry-point protocol, and installation extra are finalized.
|
|
36
|
+
4. Update `project.version` in `pyproject.toml`, add release notes, and keep the
|
|
37
|
+
version in the Git tag synchronized with package metadata.
|
|
38
|
+
|
|
39
|
+
## TestPyPI verification
|
|
40
|
+
|
|
41
|
+
Upload the built artifacts and test installation of the core package without
|
|
42
|
+
optional extras:
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
python -m twine upload --repository testpypi dist/*
|
|
46
|
+
python -m venv /tmp/bibliography-io-testpypi
|
|
47
|
+
/tmp/bibliography-io-testpypi/bin/python -m pip install \
|
|
48
|
+
--index-url https://test.pypi.org/simple/ \
|
|
49
|
+
--extra-index-url https://pypi.org/simple/ \
|
|
50
|
+
"bibliography-io==0.1.0"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Repeat the installed-wheel smoke test against the TestPyPI installation. The
|
|
54
|
+
`--extra-index-url` allows runtime dependencies not mirrored on TestPyPI to
|
|
55
|
+
resolve from PyPI.
|
|
56
|
+
|
|
57
|
+
## PyPI publication with GitHub Actions
|
|
58
|
+
|
|
59
|
+
`.github/workflows/publish.yml` builds distributions and publishes them to PyPI
|
|
60
|
+
when a GitHub Release is published. Before using it:
|
|
61
|
+
|
|
62
|
+
1. Create the `bibliography-io` project on PyPI and configure a Trusted
|
|
63
|
+
Publisher for this repository, the `publish.yml` workflow, and the `pypi`
|
|
64
|
+
environment.
|
|
65
|
+
2. Create the matching GitHub `pypi` environment and configure any required
|
|
66
|
+
protection rules.
|
|
67
|
+
3. Publish only after CI and TestPyPI verification pass. Use a `v<version>` tag
|
|
68
|
+
matching `project.version` (for example, `v0.1.0`).
|
|
69
|
+
|
|
70
|
+
## Compatibility status
|
|
71
|
+
|
|
72
|
+
The standalone bibliography-io API and its format-specific data fixtures are
|
|
73
|
+
covered without CoLRev or GROBID. Historical CoLRev-facing compatibility
|
|
74
|
+
wrappers are outside the standalone test suite. Markdown reference-list parsing
|
|
75
|
+
is optional and remains unverified until its backend is finalized and tested.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation.
|
|
2
|
+
|
|
3
|
+
SPHINXOPTS ?=
|
|
4
|
+
SPHINXBUILD ?= sphinx-build
|
|
5
|
+
SOURCEDIR = .
|
|
6
|
+
BUILDDIR = _build
|
|
7
|
+
|
|
8
|
+
.PHONY: help Makefile
|
|
9
|
+
|
|
10
|
+
help:
|
|
11
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
12
|
+
|
|
13
|
+
%: Makefile
|
|
14
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
API reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
The strict standalone public API is:
|
|
5
|
+
|
|
6
|
+
File operations infer formats from filename suffixes unless an explicit
|
|
7
|
+
``format`` is provided. String operations require ``format``. See
|
|
8
|
+
:doc:`usage` for the read/write format matrix, including the distinction
|
|
9
|
+
between core Markdown table output and pending optional reference-list parsing.
|
|
10
|
+
|
|
11
|
+
.. autofunction:: bibliography_io.load_records
|
|
12
|
+
|
|
13
|
+
.. autofunction:: bibliography_io.loads
|
|
14
|
+
|
|
15
|
+
.. autofunction:: bibliography_io.write_records
|
|
16
|
+
|
|
17
|
+
.. autofunction:: bibliography_io.dumps
|
|
18
|
+
|
|
19
|
+
The historical names ``load``, ``write``, ``write_file``, ``to_string``,
|
|
20
|
+
``load_df``, and ``get_nr_records`` are deprecated immediately. They remain
|
|
21
|
+
available during migration and will be removed in a future release.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from importlib.metadata import version as distribution_version
|
|
3
|
+
|
|
4
|
+
project = "bibliography-io"
|
|
5
|
+
author = "Gerit Wagner"
|
|
6
|
+
copyright = f"{datetime.now().year}, {author}"
|
|
7
|
+
release = distribution_version("bibliography-io")
|
|
8
|
+
|
|
9
|
+
extensions = [
|
|
10
|
+
"sphinx.ext.autodoc",
|
|
11
|
+
"sphinx.ext.napoleon",
|
|
12
|
+
"sphinx_copybutton",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
templates_path = ["_templates"]
|
|
16
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
17
|
+
|
|
18
|
+
autodoc_member_order = "bysource"
|
|
19
|
+
autodoc_typehints = "description"
|
|
20
|
+
|
|
21
|
+
html_theme = "sphinx_rtd_theme"
|
|
22
|
+
html_title = "bibliography-io documentation"
|
|
23
|
+
html_baseurl = "https://colrev-environment.github.io/bibliography-io/"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
bibliography-io
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
``bibliography-io`` provides standalone APIs for loading and writing
|
|
5
|
+
bibliographic records. Core use does not require CoLRev or GROBID.
|
|
6
|
+
|
|
7
|
+
Installation
|
|
8
|
+
------------
|
|
9
|
+
|
|
10
|
+
Install the core package with:
|
|
11
|
+
|
|
12
|
+
.. code-block:: console
|
|
13
|
+
|
|
14
|
+
python -m pip install bibliography-io
|
|
15
|
+
|
|
16
|
+
The optional ``colrev`` extra is for legacy compatibility modules, not the
|
|
17
|
+
standalone core API. Markdown reference-list parsing is pending an optional
|
|
18
|
+
backend; Markdown table writing is included in the core.
|
|
19
|
+
|
|
20
|
+
Quick example
|
|
21
|
+
-------------
|
|
22
|
+
|
|
23
|
+
.. code-block:: python
|
|
24
|
+
|
|
25
|
+
from bibliography_io import load_records, write_records
|
|
26
|
+
|
|
27
|
+
records = load_records("references.bib")
|
|
28
|
+
write_records(records, "references.ris")
|
|
29
|
+
|
|
30
|
+
File APIs infer formats from recognized filename suffixes. String APIs require
|
|
31
|
+
an explicit format:
|
|
32
|
+
|
|
33
|
+
.. code-block:: python
|
|
34
|
+
|
|
35
|
+
from bibliography_io import dumps, loads
|
|
36
|
+
|
|
37
|
+
records = loads("@article{example, title={An example}}", format="bib")
|
|
38
|
+
bibtex = dumps(records, format="bib")
|
|
39
|
+
|
|
40
|
+
See :doc:`usage` for supported formats and :doc:`api` for the public interface.
|
|
41
|
+
|
|
42
|
+
.. toctree::
|
|
43
|
+
:maxdepth: 2
|
|
44
|
+
:caption: Documentation
|
|
45
|
+
|
|
46
|
+
usage
|
|
47
|
+
api
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
if "%SPHINXBUILD%" == "" (
|
|
6
|
+
set SPHINXBUILD=sphinx-build
|
|
7
|
+
)
|
|
8
|
+
set SOURCEDIR=.
|
|
9
|
+
set BUILDDIR=_build
|
|
10
|
+
|
|
11
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
12
|
+
if errorlevel 9009 (
|
|
13
|
+
echo.
|
|
14
|
+
echo.The 'sphinx-build' command was not found. Make sure Sphinx is installed.
|
|
15
|
+
echo.
|
|
16
|
+
popd
|
|
17
|
+
exit /b 1
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
21
|
+
popd
|