Skip to content

Commit 346ef3a

Browse files
committed
remove traces of camelCase in API
1 parent 9c76b7b commit 346ef3a

File tree

7 files changed

+47
-46
lines changed

7 files changed

+47
-46
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
- Remove traces of camelCase in API (#200)
11+
812
## [3.6.0] - 2024-10-15
913

1014
### Added

libzim/libzim.pyx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,16 @@ cdef class _Creator:
314314
self.c_creator.configIndexing(indexing, language.encode('UTF-8'))
315315
return self
316316

317-
def config_nbworkers(self, int nbWorkers: pyint) -> Creator:
317+
def config_nbworkers(self, int nb_workers: pyint) -> Creator:
318318
"""Number of thread to use for internal worker"""
319319
if self._started:
320320
raise RuntimeError("Creator started")
321-
self.c_creator.configNbWorkers(nbWorkers)
321+
self.c_creator.configNbWorkers(nb_workers)
322322
return self
323323

324-
def set_mainpath(self, str mainPath: str) -> Creator:
324+
def set_mainpath(self, str main_path: str) -> Creator:
325325
"""Set path of the main entry"""
326-
self.c_creator.setMainPath(mainPath.encode('UTF-8'))
326+
self.c_creator.setMainPath(main_path.encode('UTF-8'))
327327
return self
328328

329329
def add_illustration(self, int size: pyint, content: bytes):
@@ -381,7 +381,7 @@ cdef class _Creator:
381381
with nogil:
382382
self.c_creator.addMetadata(_name, _content, _mimetype)
383383

384-
def add_redirection(self, str path: str, str title: str, str targetPath: str, dict hints: Dict[Hint, pyint]):
384+
def add_redirection(self, str path: str, str title: str, str target_path: str, dict hints: Dict[Hint, pyint]):
385385
"""Add redirection entry to Archive
386386
387387
https://wiki.openzim.org/wiki/ZIM_file_format#Redirect_Entry
@@ -396,25 +396,25 @@ cdef class _Creator:
396396

397397
cdef string _path = path.encode('UTF-8')
398398
cdef string _title = title.encode('UTF-8')
399-
cdef string _targetPath = targetPath.encode('UTF-8')
399+
cdef string _targetPath = target_path.encode('UTF-8')
400400
cdef map[zim.HintKeys, uint64_t] _hints = convertToCppHints(hints)
401401
with nogil:
402402
self.c_creator.addRedirection(_path, _title, _targetPath, _hints)
403403

404-
def add_alias(self, str path: str, str title: str, str targetPath: str, dict hints: Dict[Hint, pyint]):
405-
"""Alias the (existing) entry `targetPath` as a new entry `path`.
404+
def add_alias(self, str path: str, str title: str, str target_path: str, dict hints: Dict[Hint, pyint]):
405+
"""Alias the (existing) entry `target_path` as a new entry `path`.
406406
407407
Raises
408408
------
409409
RuntimeError
410-
If `targetPath` entry doesn't exist.
410+
If `target_path` entry doesn't exist.
411411
"""
412412
if not self._started:
413413
raise RuntimeError("Creator not started")
414414

415415
cdef string _path = path.encode('UTF-8')
416416
cdef string _title = title.encode('UTF-8')
417-
cdef string _targetPath = targetPath.encode('UTF-8')
417+
cdef string _targetPath = target_path.encode('UTF-8')
418418
cdef map[zim.HintKeys, uint64_t] _hints = convertToCppHints(hints)
419419
with nogil:
420420
self.c_creator.addAlias(_path, _title, _targetPath, _hints)
@@ -1110,11 +1110,11 @@ cdef class Search:
11101110
search.c_search = move(_search)
11111111
return search
11121112

1113-
def getEstimatedMatches(self) -> pyint:
1113+
def get_estimated_matches(self) -> pyint:
11141114
"""Estimated number of results in Archive for the search"""
11151115
return self.c_search.getEstimatedMatches()
11161116

1117-
def getResults(self, start: pyint, count: pyint) -> SearchResultSet:
1117+
def get_results(self, start: pyint, count: pyint) -> SearchResultSet:
11181118
"""Iterator over Entry paths found in Archive for the search"""
11191119
return SearchResultSet.from_resultset(move(self.c_search.getResults(start, count)))
11201120

@@ -1155,7 +1155,7 @@ archive = libzim.reader.Archive(fpath)
11551155
searcher = Searcher(archive)
11561156
query = Query().set_query("foo")
11571157
search = searcher.search(query)
1158-
for path in search.getResults(10, 10) # get result from 10 to 20 (10 results)
1158+
for path in search.get_results(10, 10) # get result from 10 to 20 (10 results)
11591159
print(path, archive.get_entry_by_path(path).title)"""
11601160
search_public_objects = [
11611161
Query,
@@ -1212,11 +1212,11 @@ cdef class SuggestionSearch:
12121212
search.c_search = move(_search)
12131213
return search
12141214

1215-
def getEstimatedMatches(self) -> pyint:
1215+
def get_estimated_matches(self) -> pyint:
12161216
"""Estimated number of results in Archive for the suggestion search"""
12171217
return self.c_search.getEstimatedMatches()
12181218

1219-
def getResults(self, start: pyint, count: pyint) -> SuggestionResultSet:
1219+
def get_results(self, start: pyint, count: pyint) -> SuggestionResultSet:
12201220
"""Iterator over Entry paths found in Archive for the suggestion search"""
12211221
return SuggestionResultSet.from_resultset(move(self.c_search.getResults(start, count)))
12221222

@@ -1255,7 +1255,7 @@ Usage:
12551255
archive = Archive(fpath)
12561256
suggestion_searcher = SuggestionSearcher(archive)
12571257
suggestions = suggestion_searcher.suggest("foo")
1258-
for path in suggestion.getResults(10, 10) # get result from 10 to 20 (10 results)
1258+
for path in suggestion.get_results(10, 10) # get result from 10 to 20 (10 results)
12591259
print(path, archive.get_entry_by_path(path).title)"""
12601260
suggestion_public_objects = [
12611261
SuggestionSearcher
@@ -1334,4 +1334,3 @@ class ModuleFinder(importlib.abc.MetaPathFinder):
13341334
sys.meta_path.insert(0, ModuleFinder())
13351335

13361336
__all__ = ["writer", "reader", "search", "suggestion", "version"]
1337-

libzim/search.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class SearchResultSet:
1212
def __iter__(self) -> Iterator[str]: ...
1313

1414
class Search:
15-
def getEstimatedMatches(self) -> int: ... # noqa: N802
16-
def getResults(self, start: int, count: int) -> SearchResultSet: ... # noqa: N802
15+
def get_estimated_matches(self) -> int: ...
16+
def get_results(self, start: int, count: int) -> SearchResultSet: ...
1717

1818
class Searcher:
1919
def __init__(self, archive: Archive) -> None: ...

libzim/suggestion.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ class SuggestionResultSet:
88
def __iter__(self) -> Iterator[str]: ...
99

1010
class SuggestionSearch:
11-
def getEstimatedMatches(self) -> int: ... # noqa: N802
12-
def getResults( # noqa: N802
13-
self, start: int, count: int
14-
) -> SuggestionResultSet: ...
11+
def get_estimated_matches(self) -> int: ...
12+
def get_results(self, start: int, count: int) -> SuggestionResultSet: ...
1513

1614
class SuggestionSearcher:
1715
def __init__(self, archive: Archive) -> None: ...

libzim/writer.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class Creator:
5858
def config_compression(self, compression: Compression | str) -> Self: ...
5959
def config_clustersize(self, size: int) -> Self: ...
6060
def config_indexing(self, indexing: bool, language: str) -> Self: ...
61-
def config_nbworkers(self, nbWorkers: int) -> Self: ... # noqa: N803
62-
def set_mainpath(self, mainPath: str) -> Self: ... # noqa: N803
61+
def config_nbworkers(self, nb_workers: int) -> Self: ...
62+
def set_mainpath(self, main_path: str) -> Self: ...
6363
def add_illustration(self, size: int, content: bytes) -> None: ...
6464
def add_item(self, writer_item: Item) -> None: ...
6565
def add_metadata(
@@ -72,14 +72,14 @@ class Creator:
7272
self,
7373
path: str,
7474
title: str,
75-
targetPath: str, # noqa: N803
75+
target_path: str,
7676
hints: dict[Hint, int],
7777
) -> None: ...
7878
def add_alias(
7979
self,
8080
path: str,
8181
title: str,
82-
targetPath: str, # noqa: N803
82+
target_path: str,
8383
hints: dict[Hint, int],
8484
) -> None: ...
8585
def __enter__(self) -> Self: ...

tests/test_libzim_creator.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def test_creator_indexing(fpath, lipsum_item, indexing, language, expected):
244244
query = Query().set_query("standard")
245245
searcher = Searcher(zim)
246246
search = searcher.search(query)
247-
assert search.getEstimatedMatches() == expected
247+
assert search.get_estimated_matches() == expected
248248

249249

250250
@pytest.mark.parametrize("nb_workers", [1, 2, 3, 5])
@@ -472,10 +472,10 @@ def test_creator_redirection(fpath, lipsum_item):
472472
# suggestions
473473
sugg_searcher = SuggestionSearcher(zim)
474474
sugg_hello = sugg_searcher.suggest("hello")
475-
assert "home" in list(sugg_hello.getResults(0, sugg_hello.getEstimatedMatches()))
475+
assert "home" in list(sugg_hello.get_results(0, sugg_hello.get_estimated_matches()))
476476
sugg_bonjour = sugg_searcher.suggest("bonjour")
477477
assert "accueil" in list(
478-
sugg_bonjour.getResults(0, sugg_hello.getEstimatedMatches())
478+
sugg_bonjour.get_results(0, sugg_hello.get_estimated_matches())
479479
)
480480

481481

@@ -659,7 +659,7 @@ def test_hints_values(fpath):
659659
# Hint values are casted to bool
660660
c.add_item(StaticItem(path="3", title="", hints={Hint.FRONT_ARTICLE: "world"}))
661661
c.add_redirection(
662-
path="4", title="", targetPath="0", hints={Hint.COMPRESS: True}
662+
path="4", title="", target_path="0", hints={Hint.COMPRESS: True}
663663
)
664664
# filtered-out values
665665
c.add_item(StaticItem(path="5", title="", hints={5: True}))
@@ -683,13 +683,13 @@ def test_hints_values(fpath):
683683
c.add_redirection( # pyright: ignore [reportCallIssue]
684684
path="5",
685685
title="",
686-
targetPath="0",
686+
target_path="0",
687687
hints={Hint.YOLO: True}, # pyright: ignore [reportAttributeAccessIssue]
688688
)
689689

690690

691691
@pytest.mark.parametrize(
692-
"indexData, customContent, search_expected",
692+
"index_data, custom_content, search_expected",
693693
[
694694
(None, "", [("standard", 1), ("home", 0), ("computer", 0)]),
695695
(False, "", [("standard", 1), ("home", 0), ("computer", 0)]),
@@ -699,22 +699,22 @@ def test_hints_values(fpath):
699699
],
700700
)
701701
def test_custom_indexdata(
702-
fpath, lipsum_item, lipsum, indexData, customContent, search_expected
702+
fpath, lipsum_item, lipsum, index_data, custom_content, search_expected
703703
):
704704
item = StaticItem(path=HOME_PATH + "custom", content=lipsum, mimetype="text/html")
705-
if indexData is None:
705+
if index_data is None:
706706
item.get_indexdata = lambda: None
707707
else:
708708

709709
class CustomIndexData(IndexData):
710710
def has_indexdata(self):
711-
return indexData
711+
return index_data
712712

713713
def get_title(self):
714714
return ""
715715

716716
def get_content(self):
717-
return customContent
717+
return custom_content
718718

719719
def get_keywords(self):
720720
return ""
@@ -733,7 +733,7 @@ def get_wordcount(self):
733733
for search_query, expected in search_expected:
734734
query = Query().set_query(search_query)
735735
search = searcher.search(query)
736-
assert search.getEstimatedMatches() == expected
736+
assert search.get_estimated_matches() == expected
737737

738738

739739
def test_indexdata_interface():
@@ -871,11 +871,11 @@ def test_accented_search_from_libzim(fpath):
871871
ascii_query = Query().set_query("test article")
872872
ascii_searcher = Searcher(zim)
873873
ascii_search = ascii_searcher.search(ascii_query)
874-
assert ascii_search.getEstimatedMatches() == zim.article_count
875-
assert list(ascii_search.getResults(0, zim.article_count)) == ["path0", "path1"]
874+
assert ascii_search.get_estimated_matches() == zim.article_count
875+
assert list(ascii_search.get_results(0, zim.article_count)) == ["path0", "path1"]
876876

877877
accented_query = Query().set_query("test àrticlé")
878878
accented_searcher = Searcher(zim)
879879
accented_search = accented_searcher.search(accented_query)
880-
assert accented_search.getEstimatedMatches() == zim.article_count
881-
assert list(accented_search.getResults(0, zim.article_count)) == ["path0", "path1"]
880+
assert accented_search.get_estimated_matches() == zim.article_count
881+
assert list(accented_search.get_results(0, zim.article_count)) == ["path0", "path1"]

tests/test_libzim_reader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,14 @@ def test_reader_suggest_search(
478478
query = Query().set_query(search_string)
479479
searcher = Searcher(zim)
480480
search = searcher.search(query)
481-
assert search.getEstimatedMatches() == search_count
482-
assert list(search.getResults(0, search_count)) == search_result
481+
assert search.get_estimated_matches() == search_count
482+
assert list(search.get_results(0, search_count)) == search_result
483483

484484
if suggestion_string is not None:
485485
suggestion_searcher = SuggestionSearcher(zim)
486486
suggestion = suggestion_searcher.suggest(suggestion_string)
487-
assert suggestion.getEstimatedMatches() == suggestion_count
488-
assert list(suggestion.getResults(0, suggestion_count)) == suggestion_result
487+
assert suggestion.get_estimated_matches() == suggestion_count
488+
assert list(suggestion.get_results(0, suggestion_count)) == suggestion_result
489489

490490

491491
@skip_if_offline

0 commit comments

Comments
 (0)