Skip to content

Commit 29f976a

Browse files
author
renaud gaudin
committed
Added doc regarding get_entry_by_title behavior
As get_entry_by_title behavior changes based on how the ZIM was created, it's important user is informed of this. As a result, it is clear that example.zim in tests cannot be searched by title at all so this test was removed
1 parent bbe6c96 commit 29f976a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libzim/libzim.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,19 @@ cdef class Archive:
759759
return Entry.from_entry(move(entry))
760760

761761
def has_entry_by_title(self, title: str) -> pybool:
762-
"""Whether Archive has en entry with this title"""
762+
"""Whether Archive has en entry with this title
763+
764+
Uses get_entry_by_title() so it's specificities apply as well"""
763765
return self.c_archive.hasEntryByTitle(<string>title.encode('UTF-8'))
764766

765767
def get_entry_by_title(self, title: str) -> Entry:
766768
"""Entry from a title -> Entry
767769

770+
If ZIM doesn't contain a listing/titleOrdered/v1 entry (most likely
771+
because if was created without any FRONT_ARTICLE) then this yields results
772+
for matching path if the title was not set at creation time.
773+
Otherwise raises KeyError.
774+
768775
Parameters
769776
----------
770777
title : str

tests/test_libzim_reader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ def test_reader_get_entries(
469469
with pytest.raises(KeyError):
470470
zim.get_entry_by_title("___missing")
471471

472-
# FIXME: unable to retrieve entry by title on example.zim
472+
# example.zim cannot be queried by title as all its entries have been created
473+
# with empty titles but the ZIM contains a v1 title listing.
473474
if test_title and filename != "example.zim":
474475
assert zim.has_entry_by_title(test_title)
475476
assert zim.get_entry_by_title(test_title).path == entry.path

0 commit comments

Comments
 (0)