-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from openzim/types
Introducing Type Hints
- Loading branch information
Showing
13 changed files
with
281 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from libzim import ( | ||
reader, # noqa: F401 # pyright: ignore[reportUnusedImport] | ||
search, # noqa: F401 # pyright: ignore[reportUnusedImport] | ||
suggestion, # noqa: F401 # pyright: ignore[reportUnusedImport] | ||
version, # noqa: F401 # pyright: ignore[reportUnusedImport] | ||
writer, # noqa: F401 # pyright: ignore[reportUnusedImport] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
from uuid import UUID | ||
|
||
class Item: | ||
@property | ||
def title(self) -> str: ... | ||
@property | ||
def path(self) -> str: ... | ||
@property | ||
def content(self) -> memoryview: ... | ||
@property | ||
def mimetype(self) -> str: ... | ||
@property | ||
def _index(self) -> int: ... | ||
@property | ||
def size(self) -> int: ... | ||
def __repr__(self) -> str: ... | ||
|
||
class Entry: | ||
@property | ||
def title(self) -> str: ... | ||
@property | ||
def path(self) -> str: ... | ||
@property | ||
def _index(self) -> int: ... | ||
@property | ||
def is_redirect(self) -> bool: ... | ||
def get_redirect_entry(self) -> Entry: ... | ||
def get_item(self) -> Item: ... | ||
def __repr__(self) -> str: ... | ||
|
||
class Archive: | ||
def __init__(self, filename: pathlib.Path) -> None: ... | ||
@property | ||
def filename(self) -> pathlib.Path: ... | ||
@property | ||
def filesize(self) -> int: ... | ||
def has_entry_by_path(self, path: str) -> bool: ... | ||
def get_entry_by_path(self, path: str) -> Entry: ... | ||
def has_entry_by_title(self, title: str) -> bool: ... | ||
def get_entry_by_title(self, title: str) -> Entry: ... | ||
@property | ||
def metadata_keys(self) -> list[str]: ... | ||
def get_metadata_item(self, name: str) -> Item: ... | ||
def get_metadata(self, name: str) -> bytes: ... | ||
def _get_entry_by_id(self, entry_id: int) -> Entry: ... | ||
@property | ||
def has_main_entry(self) -> bool: ... | ||
@property | ||
def main_entry(self) -> Entry: ... | ||
@property | ||
def uuid(self) -> UUID: ... | ||
@property | ||
def has_new_namespace_scheme(self) -> bool: ... | ||
@property | ||
def is_multipart(self) -> bool: ... | ||
@property | ||
def has_fulltext_index(self) -> bool: ... | ||
@property | ||
def has_title_index(self) -> bool: ... | ||
@property | ||
def has_checksum(self) -> str: ... | ||
@property | ||
def checksum(self) -> str: ... | ||
def check(self) -> bool: ... | ||
@property | ||
def entry_count(self) -> int: ... | ||
@property | ||
def all_entry_count(self) -> int: ... | ||
@property | ||
def article_count(self) -> int: ... | ||
@property | ||
def media_count(self) -> int: ... | ||
def get_illustration_sizes(self) -> set[int]: ... | ||
def has_illustration(self, size: int | None = None) -> bool: ... | ||
def get_illustration_item(self, size: int | None = None) -> Item: ... | ||
def __repr__(self) -> str: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterator | ||
from typing import Self | ||
|
||
from libzim.reader import Archive | ||
|
||
class Query: | ||
def set_query(self, query: str) -> Self: ... | ||
|
||
class SearchResultSet: | ||
def __iter__(self) -> Iterator[str]: ... | ||
|
||
class Search: | ||
def getEstimatedMatches(self) -> int: ... # noqa: N802 | ||
def getResults(self, start: int, count: int) -> SearchResultSet: ... # noqa: N802 | ||
|
||
class Searcher: | ||
def __init__(self, archive: Archive) -> None: ... | ||
def search(self, query: Query) -> Search: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterator | ||
|
||
from libzim.reader import Archive | ||
|
||
class SuggestionResultSet: | ||
def __iter__(self) -> Iterator[str]: ... | ||
|
||
class SuggestionSearch: | ||
def getEstimatedMatches(self) -> int: ... # noqa: N802 | ||
def getResults( # noqa: N802 | ||
self, start: int, count: int | ||
) -> SuggestionResultSet: ... | ||
|
||
class SuggestionSearcher: | ||
def __init__(self, archive: Archive) -> None: ... | ||
def suggest(self, query: str) -> SuggestionSearch: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from collections import OrderedDict | ||
from typing import TextIO | ||
|
||
def print_versions(out: TextIO = sys.stdout) -> None: ... | ||
def get_versions() -> OrderedDict[str, str]: ... | ||
def get_libzim_version() -> str: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from __future__ import annotations | ||
|
||
import datetime | ||
import enum | ||
import pathlib | ||
import types | ||
from collections.abc import Callable, Generator | ||
from typing import Self | ||
|
||
class Compression(enum.Enum): | ||
none: Self | ||
zstd: Self | ||
|
||
class Hint(enum.Enum): | ||
COMPRESS: Self | ||
FRONT_ARTICLE: Self | ||
|
||
class Blob: | ||
def __init__(self, content: str | bytes) -> None: ... | ||
def size(self) -> int: ... | ||
ref_content: bytes | ||
|
||
class ContentProvider: | ||
def feed(self) -> Blob: ... | ||
def get_size(self) -> int: ... | ||
def gen_blob(self) -> Generator[Blob, None, None]: ... | ||
|
||
generator: Generator[Blob, None, None] | ||
|
||
class StringProvider(ContentProvider): | ||
def __init__(self, content: str | bytes) -> None: ... | ||
|
||
class FileProvider(ContentProvider): | ||
def __init__(self, filepath: pathlib.Path | str) -> None: ... | ||
|
||
class Item: | ||
def get_path(self) -> str: ... | ||
def get_title(self) -> str: ... | ||
def get_mimetype(self) -> str: ... | ||
def get_contentprovider(self) -> ContentProvider: ... | ||
def get_hints(self) -> dict[Hint, int]: ... | ||
def __repr__(self) -> str: ... | ||
|
||
get_indexdata: Callable[[], IndexData | None] | None | ||
_blob: Blob | ||
|
||
class IndexData: | ||
def has_indexdata(self) -> bool: ... | ||
def get_title(self) -> str: ... | ||
def get_content(self) -> str: ... | ||
def get_keywords(self) -> str: ... | ||
def get_wordcount(self) -> int: ... | ||
def get_geoposition(self) -> tuple[float, float] | None: ... | ||
|
||
class Creator: | ||
def __init__(self, filename: pathlib.Path) -> None: ... | ||
def config_verbose(self, verbose: bool) -> Self: ... | ||
def config_compression(self, compression: Compression | str) -> Self: ... | ||
def config_clustersize(self, size: int) -> Self: ... | ||
def config_indexing(self, indexing: bool, language: str) -> Self: ... | ||
def config_nbworkers(self, nbWorkers: int) -> Self: ... # noqa: N803 | ||
def set_mainpath(self, mainPath: str) -> Self: ... # noqa: N803 | ||
def add_illustration(self, size: int, content: bytes) -> None: ... | ||
def add_item(self, writer_item: Item) -> None: ... | ||
def add_metadata( | ||
self, | ||
name: str, | ||
content: str | bytes | datetime.date | datetime.datetime, | ||
mimetype: str = "text/plain;charset=UTF-8", | ||
) -> None: ... | ||
def add_redirection( | ||
self, | ||
path: str, | ||
title: str, | ||
targetPath: str, # noqa: N803 | ||
hints: dict[Hint, int], | ||
) -> None: ... | ||
def add_alias( | ||
self, | ||
path: str, | ||
title: str, | ||
targetPath: str, # noqa: N803 | ||
hints: dict[Hint, int], | ||
) -> None: ... | ||
def __enter__(self) -> Self: ... | ||
def __exit__( | ||
self, | ||
exc_type: type[BaseException] | None, | ||
exc_val: BaseException | None, | ||
exc_tb: types.TracebackType | None, | ||
) -> None: ... | ||
@property | ||
def filename(self) -> pathlib.Path: ... | ||
def __repr__(self) -> str: ... | ||
|
||
_filename: pathlib.Path | ||
_started: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.