Skip to content

comicbox.version

Package name and version.

get_version()

Get the current installed comicbox version.

Source code in comicbox/version.py
11
12
13
14
15
16
17
def get_version() -> str:
    """Get the current installed comicbox version."""
    v = "dev"
    if "pytest" not in sys.modules:
        with suppress(PackageNotFoundError):
            v = version(PACKAGE_NAME)
    return v

set_user_agent_context(entry_point, jobs=None, client=None)

Record how this process drives comicbox, for the outgoing User-Agent.

entry_point is "cli" or "lib"; jobs is the worker count a batch runs with; client names an embedding application.

Call before the first online request: API clients bake the header in at construction and are memoized per credential set, so a later change does not reach a session that already exists.

Source code in comicbox/version.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def set_user_agent_context(
    entry_point: str, jobs: int | None = None, client: str | None = None
) -> None:
    """
    Record how this process drives comicbox, for the outgoing User-Agent.

    ``entry_point`` is ``"cli"`` or ``"lib"``; ``jobs`` is the worker
    count a batch runs with; ``client`` names an embedding application.

    Call before the first online request: API clients bake the header in
    at construction and are memoized per credential set, so a later
    change does not reach a session that already exists.
    """
    global _ua_entry_point, _ua_jobs, _ua_client  # noqa: PLW0603
    with _ua_lock:
        _ua_entry_point = entry_point
        _ua_jobs = jobs
        _ua_client = client

user_agent()

Return the User-Agent for outgoing API requests.

Source code in comicbox/version.py
65
66
67
68
69
70
71
72
73
def user_agent() -> str:
    """Return the User-Agent for outgoing API requests."""
    with _ua_lock:
        parts = [_ua_entry_point]
        if _ua_client:
            parts.append(_ua_client)
        if _ua_jobs and _ua_jobs > 1:
            parts.append(f"jobs={_ua_jobs}")
    return f"{USER_AGENT} ({'; '.join(parts)})"