Skip to content

Commit 2b8b016

Browse files
author
rgaudin
authored
Merge pull request #123 from openzim/illustration_size
Add support for getIllustrationSizes
2 parents dc5ef7e + 15a80ad commit 2b8b016

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

libzim/libwrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class Archive : public Wrapper<zim::Archive>
145145
FORWARD(wrapper::Entry, getEntryByTitle)
146146
FORWARD(wrapper::Entry, getMainEntry)
147147
FORWARD(wrapper::Item, getIllustrationItem)
148+
FORWARD(std::set<unsigned int>, getIllustrationSizes)
148149
std::string getUuid() const
149150
{ auto u = mp_base->getUuid();
150151
std::string uuids(u.data, u.size());

libzim/libzim.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ from uuid import UUID
4545

4646
from cpython.buffer cimport PyBUF_WRITABLE
4747
from cpython.ref cimport PyObject
48+
4849
from cython.operator import preincrement
50+
4951
from libc.stdint cimport uint64_t
5052
from libcpp cimport bool
5153
from libcpp.map cimport map
@@ -894,7 +896,7 @@ cdef class Archive:
894896

895897
def get_illustration_sizes(self) -> Set[pyint]:
896898
"""Sizes for which an illustration is available (@1 scale only)"""
897-
return {48}
899+
return self.c_archive.getIllustrationSizes()
898900

899901
def has_illustration(self, size: pyint = None) -> pybool:
900902
"""Whether Archive has an illustration metadata for this size"""

libzim/zim.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from libc.stdint cimport uint32_t, uint64_t
2222
from libcpp cimport bool
2323
from libcpp.map cimport map
2424
from libcpp.memory cimport shared_ptr
25+
from libcpp.set cimport set
2526
from libcpp.string cimport string
2627
from libcpp.vector cimport vector
2728

@@ -153,7 +154,7 @@ cdef extern from "libwrapper.h" namespace "wrapper":
153154
bool hasMainEntry() except +
154155
bool hasIllustration() except +
155156
bool hasIllustration(unsigned int size) except +
156-
# set[unsigned int] getIllustrationSizes() except +
157+
set[unsigned int] getIllustrationSizes() except +
157158
bool hasEntryByPath(string path) except +
158159
bool hasEntryByTitle(string title) except +
159160
bool isMultiPart() except +

tests/test_libzim_creator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def test_creator_illustration(fpath, favicon_data):
350350
assert zim.has_illustration(128) is False
351351
assert bytes(zim.get_illustration_item().content) == favicon_data
352352
assert bytes(zim.get_illustration_item(96).content) == favicon_data
353+
assert zim.get_illustration_sizes() == {48, 96}
353354

354355

355356
def test_creator_additem(fpath, lipsum_item):

tests/test_libzim_reader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def test_reader_main_favicon_entries(
345345
assert zim.get_illustration_item()
346346
if new_ns:
347347
assert zim.get_illustration_item().path == "Illustration_48x48@1"
348+
assert zim.get_illustration_sizes() == {48}
348349

349350

350351
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)