Skip to content

Commit 65406a7

Browse files
committed
Merge branch 'master' of https://github.com/cldf/pycldf
2 parents 95e91dc + 3d2195c commit 65406a7

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
The `pycldf` package adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
44

5+
## unreleased
6+
7+
- Switch from `pybtex` to `simplepybtex`.
8+
- Make `Dataset.add_sources` accept a `BibliographyData` object from either `pybtex` or `simplepybtex`.
9+
- More informative error message when `Dataset.add_sources` gets the wrong type of object.
510

611
## [1.42.0] - 2025-04-07
712

setup.cfg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ install_requires =
4141
clldutils>=3.9
4242
uritemplate>=3.0
4343
python-dateutil
44-
# pybtex requires setuptools, but doesn't seem to declare this.
45-
setuptools
46-
pybtex
44+
simplepybtex
4745
newick
4846
commonnexus>=1.2.0
4947
python-frontmatter

src/pycldf/sources.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def __repr__(self):
5858
@classmethod
5959
def from_entry(cls, key, entry, **_kw):
6060
"""
61-
Create a `cls` instance from a `pybtex` entry object.
61+
Create a `cls` instance from a `simplepybtex` entry object.
6262
6363
:param key: BibTeX citation key of the entry
64-
:param entry: `pybtex.database.Entry` instance
64+
:param entry: `simplepybtex.database.Entry` instance
6565
:param _kw: Non-bib-metadata keywords to be passed for `cls` instantiation
6666
:return: `cls` instance
6767
"""
@@ -220,10 +220,15 @@ def expand_refs(self, refs: typing.Iterable[str], **kw) -> typing.Iterable[Refer
220220
def _add_entries(self, data, **kw):
221221
if isinstance(data, Source):
222222
entries = [(data.id, data.entry)]
223-
elif isinstance(data, database.BibliographyData):
223+
elif hasattr(data, 'entries'):
224224
entries = data.entries.items()
225225
else:
226-
raise ValueError(data)
226+
msg = (
227+
'expected `clldutils.source.Source`,'
228+
' `pybtex.database.BibliographyData`,'
229+
' or `simplepybtex.database.BibliographyData`;'
230+
f' got {type(data)}')
231+
raise TypeError(data)
227232

228233
for key, entry in entries:
229234
if kw.get('_check_id', False) and not ID_PATTERN.match(key):

tests/test_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_Sources(bib):
7474
refs = ['huber2005[1-6]', 'Obrazy', 'Elegie[34]']
7575
assert src.format_refs(*list(src.expand_refs(refs))) == refs
7676
assert '%s' % src['huber2005'] == 'Huber, Herrmann. 2005. y.'
77-
with pytest.raises(ValueError):
77+
with pytest.raises(TypeError):
7878
src.add(5)
7979

8080
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)