Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xrotwang committed Apr 12, 2024
1 parent c57f5f3 commit 65cbcdb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = clld-audio-plugin
version = 1.1.1.dev0
version = 1.2.0
license_file = LICENSE
author = Robert Forkel
author_email = [email protected]
Expand Down
9 changes: 6 additions & 3 deletions src/clld_audio_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ def form2audio(cldf, mimetype='audio/mpeg'):
:return: `dict` mapping form ID to audio file.
"""
res = {}
for r in cldf.iter_rows('media.csv', 'id', 'formReference'):
if r['mimetype'] == mimetype:
res[r['formReference']] = cldf.get_row_url('media.csv', r)
table = 'MediaTable' if 'MediaTable' in cldf else 'media.csv'
with_mediaType = (table, 'mediaType') in cldf
props = ['mediaType'] if with_mediaType else []
for r in cldf.iter_rows(table, 'id', 'formReference', 'mediaType', *props):
if r['mediaType' if with_mediaType else 'mimetype'] == mimetype:
res[r['formReference']] = cldf.get_row_url(table, r)
return res
2 changes: 1 addition & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_AudioCol(mocker):


def test_form2audio(mocker):
res =form2audio(mocker.Mock(
res = form2audio(mocker.MagicMock(
iter_rows=lambda *args: [dict(mimetype='audio/mpeg', formReference='x')],
get_row_url=lambda *args: 'http://example.org'))
assert res['x'] == 'http://example.org'
Expand Down

0 comments on commit 65cbcdb

Please sign in to comment.