# Copyright (C) 2023 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later from typing import Any, Callable, Literal, Optional, Protocol LOG_DEBUG: int LOG_ERROR: int LOG_FUNCTION: int LOG_WARNING: int PKG_REASON_DEPEND: int PKG_REASON_EXPLICIT: int SIG_DATABASE: int SIG_DATABASE_MARGINAL_OK: int SIG_DATABASE_OPTIONAL: int SIG_DATABASE_UNKNOWN_OK: int SIG_PACKAGE: int SIG_PACKAGE_MARGINAL_OK: int SIG_PACKAGE_OPTIONAL: int SIG_PACKAGE_UNKNOWN_OK: int class _LogCB(Protocol): def __call__(self, loglevel: int, msg: str) -> None: ... class _DLCB(Protocol): def __call__(self, filename: str, transferred: int, total: int) -> None: ... class _FetchCB(Protocol): # return value: # - 0 : success # - 1 : file_exists # - -1 : error def __call__(self, url: str, dstpath: str, force: bool) -> Literal[0, 1, -1]: ... class _EventCB(Protocol): def __call__(self, event_id: int, event_str: str) -> None: ... class _QuestionCB(Protocol): # transaction.c:pyalpm_questioncb isn't implemented def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class _ProgressCB(Protocol): def __call__( self, target_name: str, percentage: int, n_targets: int, cur_target: int ) -> None: ... class Handle: # filepaths root: str dbpath: str logfile: str lockfile: str gpgdir: str # strings arch: str # booleans usesyslog: bool checkspace: bool # lists cachedirs: list[str] noupgrades: list[str] noextracts: list[str] ignorepkgs: list[str] ignoregrps: list[str] # callbacks logcb: Optional[_LogCB] dlcb: Optional[_DLCB] fetchcb: Optional[_FetchCB] eventcb: Optional[_EventCB] questioncb: Optional[_QuestionCB] progresscb: Optional[_ProgressCB] def __init__(cls, rootpath: str, dbpath: str) -> None: ... # add to lists def add_cachedir(self, path: str) -> None: ... def add_ignoregrp(self, groupname: str) -> None: ... def add_ignorepkg(self, pkgname: str) -> None: ... def add_noextract(self, pkgname: str) -> None: ... def add_noupgrade(self, pkgname: str) -> None: ... # remove from lists def remove_cachedir(self, path: str) -> None: ... def remove_ignoregrp(self, groupname: str) -> None: ... def remove_ignorepkg(self, pkgname: str) -> None: ... def remove_noextract(self, pkgname: str) -> None: ... def remove_noupgrade(self, pkgname: str) -> None: ... # DBs def register_syncdb(self, name: str, flags: int) -> DB: ... def get_localdb(self) -> DB: ... def get_syncdbs(self) -> list[DB]: ... # Packages def load_pkg( self, filename: str, check_sig: int = SIG_DATABASE_OPTIONAL ) -> Optional[Package]: ... def set_pkgreason(self, pkg: Package, reason: int) -> None: ... # Transactions def init_transaction( self, nodeps: bool = ..., force: bool = ..., nosave: bool = ..., nodepversion: bool = ..., cascade: bool = ..., recurse: bool = ..., dbonly: bool = ..., alldeps: bool = ..., downloadonly: bool = ..., noscriptlet: bool = ..., noconflicts: bool = ..., needed: bool = ..., allexplicit: bool = ..., unneeded: bool = ..., recurseall: bool = ..., nolock: bool = ..., ) -> Transaction: ... class DB: grpcache: list[tuple[str, list[Package]]] name: str pkgcache: list[Package] servers: list[str] def get_pkg(self, pkgname: str) -> Optional[Package]: ... def read_grp(self, grpname: str) -> Optional[list[Package]]: ... def search(self, query: str) -> list[Package]: ... def update(self, force: bool) -> Literal[True]: ... class Package: db: Optional[DB] # description properties name: str version: str desc: str url: str arch: str licenses: list[str] groups: list[str] # package properties packager: str md5sum: str sha256sum: str base64_sig: str filename: str base: str size: int isize: int reason: int builddate: int installdate: int files: list[str] backup: list[str] # dependency information depends: list[str] optdepends: list[str] checkdepends: list[str] makedepends: list[str] conflicts: list[str] provides: list[str] replaces: list[str] # miscellaneous information has_scriptlet: bool download_size: int def compute_optionalfor(self) -> list[Package]: ... def compute_requiredby(self) -> list[Package]: ... class Transaction: flags: dict[str, bool] to_add: list[Package] to_remove: list[Package] # Execution flow def prepare(self) -> None: ... def commit(self) -> None: ... def interrupt(self) -> None: ... def release(self) -> None: ... # Transaction contents def add_pkg(self, pkg: Package) -> None: ... def remove_pkg(self, pkg: Package) -> None: ... def sysupgrade(self, downgrade: bool = False) -> None: ... class error(Exception): ... def version() -> str: ... def alpmversion() -> str: ... def vercmp(ver1: str, ver2: str) -> int: ... def find_satisfier(pkgs: list[Package], depstring: str) -> Optional[Package]: ... def sync_newversion(pkg: Package, dbs: list[DB]) -> Optional[Package]: ... def find_grp_pkgs(dbs: list[DB], groupname: str) -> list[Package]: ...