@@ -39,6 +39,7 @@ import os
3939import pathlib
4040import sys
4141import traceback
42+ import warnings
4243from collections import OrderedDict
4344from types import ModuleType
4445from typing import Dict, Generator, Iterator, List, Optional, Set, TextIO, Tuple, Union
@@ -1304,9 +1305,18 @@ cdef class Archive:
13041305 def get_illustration_sizes(self) -> Set[pyint]:
13051306 """ Sizes for which an illustration is available (@1 scale only).
13061307
1308+ .. deprecated:: 3.8 .0
1309+ Use :meth:`get_illustration_infos` instead for full illustration metadata
1310+ including width, height, and scale information.
1311+
13071312 Returns:
13081313 The set of available sizes of the illustration.
13091314 """
1315+ warnings.warn(
1316+ "get_illustration_sizes() is deprecated, use get_illustration_infos() instead",
1317+ DeprecationWarning,
1318+ stacklevel=2
1319+ )
13101320 return self.c_archive.getIllustrationSizes()
13111321
13121322 def has_illustration(self, size: pyint = None) -> pybool:
@@ -1332,37 +1342,6 @@ cdef class Archive:
13321342 except RuntimeError as e:
13331343 raise KeyError(str(e))
13341344
1335- @property
1336- def cluster_cache_max_size(self) -> pyint:
1337- """ Maximum size of the cluster cache.
1338-
1339- Returns:
1340- (int ): maximum number of clusters stored in the cache.
1341- """
1342- return self.c_archive.getClusterCacheMaxSize()
1343-
1344- @cluster_cache_max_size.setter
1345- def cluster_cache_max_size(self, nb_clusters: pyint):
1346- """ Set the size of the cluster cache.
1347-
1348- If the new size is lower than the number of currently stored clusters
1349- some clusters will be dropped from cache to respect the new size.
1350-
1351- Args:
1352- nb_clusters (int ): maximum number of clusters stored in the cache
1353- """
1354-
1355- self.c_archive.setClusterCacheMaxSize(nb_clusters)
1356-
1357- @property
1358- def cluster_cache_current_size(self) -> pyint:
1359- """ Size of the cluster cache.
1360-
1361- Returns:
1362- (int ): number of clusters currently stored in the cache.
1363- """
1364- return self.c_archive.getClusterCacheCurrentSize()
1365-
13661345 @property
13671346 def dirent_cache_max_size(self) -> pyint:
13681347 """ Maximum size of the dirent cache.
@@ -1393,36 +1372,38 @@ cdef class Archive:
13931372 """
13941373 return self.c_archive.getDirentCacheCurrentSize()
13951374
1396- @property
1397- def dirent_lookup_cache_max_size(self) -> pyint:
1398- """ Size of the dirent lookup cache.
1375+ def __repr__(self) -> str:
1376+ return f"{self.__class__.__name__}(filename={self.filename})"
13991377
1400- The returned size returns the default size or the last set size.
1401- This may not correspond to the actual size of the dirent lookup cache.
1402- See set_dirent_lookup_cache_max_size for more information.
14031378
1404- Returns:
1405- (int ): maximum number of sub ranges created in the lookup cache.
1406- """
1407- return self.c_archive.getDirentLookupCacheMaxSize()
1379+ def get_cluster_cache_max_size() -> pyint:
1380+ """ Get the maximum size of the cluster cache.
14081381
1409- @dirent_lookup_cache_max_size.setter
1410- def dirent_lookup_cache_max_size(self, nb_ranges: pyint):
1411- """ Set the size of the dirent lookup cache.
1382+ Returns:
1383+ (int ): the maximum memory size used by the cluster cache (in bytes).
1384+ """
1385+ return zim.getClusterCacheMaxSize()
14121386
1413- Contrary to other set_< foo> _cache_max_size, this method is useless
1414- once the lookup cache is created.
1415- The lookup cache is created at first access to a entry in the archive.
1416- So this method must be called before any access to content (including metadata).
1417- It is best to call this method first, just after the archive creation.
1387+ def set_cluster_cache_max_size(size_in_bytes: pyint):
1388+ """ Set the size of the cluster cache.
14181389
1419- Args:
1420- nb_ranges (int ): maximum number of sub ranges created in the lookup cache.
1421- """
1422- self.c_archive.setDirentLookupCacheMaxSize(nb_ranges)
1390+ If the new size is lower than the number of currently stored clusters
1391+ some clusters will be dropped from cache to respect the new size.
1392+
1393+ Args:
1394+ size_in_bytes (int ): the memory limit (in bytes) for the cluster cache.
1395+ """
1396+
1397+ zim.setClusterCacheMaxSize(size_in_bytes)
1398+
1399+ def get_cluster_cache_current_size() -> pyint:
1400+ """ Get the current size of the cluster cache.
1401+
1402+ Returns:
1403+ (int ): the current memory size (in bytes) used by the cluster cache.
1404+ """
1405+ return zim.getClusterCacheCurrentSize()
14231406
1424- def __repr__(self) -> str:
1425- return f"{self.__class__.__name__}(filename={self.filename})"
14261407
14271408reader_module_doc = """ libzim reader module
14281409
@@ -1442,6 +1423,9 @@ reader_public_objects = [
14421423 Archive,
14431424 Entry,
14441425 Item,
1426+ get_cluster_cache_max_size,
1427+ set_cluster_cache_max_size,
1428+ get_cluster_cache_current_size,
14451429]
14461430reader = create_module(reader_module_name, reader_module_doc, reader_public_objects)
14471431
0 commit comments