How to use the pyalpm.Package function in pyalpm

To help you get started, we’ve selected a few pyalpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github archlinux / pyalpm / test / test_package.py View on Github external
def test_repr(package):
    assert repr(Package) == ""
    assert PKG in repr(package)
github actionless / pikaur / pikaur / search_cli.py View on Github external
print_stderr(_("Searching... [{bar}]").format(bar='-' * progressbar_length), end='')
        print_stderr('\x1b[\bb' * (progressbar_length + 1), end='')

    with ThreadPool() as pool:
        request_local = pool.apply_async(package_search_thread_local, ())
        requests_repo = [
            pool.apply_async(package_search_thread_repo, (search_word, ))
            for search_word in (search_query or [''])
        ] if not AUR_ONLY else []
        request_aur = pool.apply_async(
            package_search_thread_aur, (search_query,)
        ) if not REPO_ONLY else None
        pool.close()

        result_local = request_local.get()
        result_repo: List[List[pyalpm.Package]] = []
        for request_repo in requests_repo:
            pkgs_found = request_repo.get()
            if pkgs_found:
                result_repo.append(pkgs_found)
        try:
            result_aur = request_aur.get() if request_aur else None
        except AURError as exc:
            print_stderr('AUR returned error: {}'.format(exc))
            raise SysExit(121)
        pool.join()

    if not args.quiet:
        sys.stderr.write('\n')

    repo_result = (
        join_search_results(result_repo)
github actionless / pikaur / pikaur / package_update.py View on Github external
result = False
    for devel_pkg_postfix in DEVEL_PKGS_POSTFIXES:
        if pkg_name.endswith(devel_pkg_postfix):
            result = True
            break
    return result


class PackageUpdate(DataType):
    name: str
    current_version: str
    new_version: str
    description: str
    repository: Optional[str] = None
    devel_pkg_age_days: Optional[int] = None
    package: Union[pyalpm.Package, AURPackageInfo]
    provided_by: Optional[List[Union[pyalpm.Package, AURPackageInfo]]] = None
    required_by: Optional[List['PackageUpdate']] = None
    members_of: Optional[List[str]] = None

    def __repr__(self) -> str:
        return (
            f'<{self.__class__.__name__} "{self.name}" '
            f'{self.current_version} -> {self.new_version}>'
        )


def find_repo_updates() -> List[PackageUpdate]:
    all_local_pkgs = PackageDB.get_local_dict()
    repo_packages_updates = []
    for repo_pkg in find_upgradeable_packages():
        local_pkg = all_local_pkgs[repo_pkg.name]
github actionless / pikaur / pikaur / print_department.py View on Github external
if PikaurConfig().ui.ReverseSearchSorting.get_bool():
        enumerated_packages = list(reversed(enumerated_packages))

    for pkg_idx, package in enumerated_packages:
        # @TODO: return only packages for the current architecture
        idx = ''
        if enumerated:
            idx = bold_line(f'{pkg_idx+1}) ')

        pkg_name = package.name
        if args.quiet:
            print(f'{idx}{pkg_name}')
        else:

            repo = color_line('aur/', 9)
            if isinstance(package, pyalpm.Package):
                repo = pretty_format_repo_name(package.db.name)

            groups = ''
            if getattr(package, 'groups', None):
                groups = color_line('({}) '.format(' '.join(package.groups)), GROUP_COLOR)

            installed = ''
            if pkg_name in local_pkgs_names:
                if package.version != local_pkgs_versions[pkg_name]:
                    installed = color_line(_("[installed: {version}]").format(
                        version=local_pkgs_versions[pkg_name],
                    ) + ' ', 14)
                else:
                    installed = color_line(_("[installed]") + ' ', 14)

            rating = ''
github actionless / pikaur / pikaur / pacman.py View on Github external
def get_pkg_id(pkg: Union['AURPackageInfo', pyalpm.Package]) -> str:
    if isinstance(pkg, pyalpm.Package):
        return f"{pkg.db.name}/{pkg.name}"
    return f"aur/{pkg.name}"
github actionless / pikaur / pikaur / print_department.py View on Github external
from .config import VERSION, PikaurConfig
from .version import get_common_version, get_version_diff
from .pacman import PackageDB
from .aur import AURPackageInfo


if TYPE_CHECKING:
    # pylint: disable=unused-import
    from .install_info_fetcher import InstallInfoFetcher  # noqa


GROUP_COLOR = 4
REPLACEMENTS_COLOR = 14


AnyPackage = Union[AURPackageInfo, pyalpm.Package]


def print_version(pacman_version: str, quiet=False) -> None:
    if quiet:
        print(f'Pikaur v{VERSION}')
        print(pacman_version)
    else:
        sys.stdout.write(r"""
      /:}               _
     /--1             / :}
    /   |           / `-/
   |  ,  --------  /   /
   |'                 Y      Pikaur v""" + VERSION + r"""
  /                   l      (C) 2018 Pikaur development team
  l  /       \        l      Licensed under GPLv3
  j  ●   .   ●        l
github actionless / pikaur / pikaur / core.py View on Github external
def package_source(self) -> PackageSource:
        if isinstance(self.package, pyalpm.Package):
            return PackageSource.REPO
        return PackageSource.AUR
github actionless / pikaur / pikaur / pacman.py View on Github external
class PacmanPrint(DataType):

    full_name: str
    repo: str
    name: str


class PacmanConfig(PycmanConfig):

    def __init__(self) -> None:
        super().__init__(conf='/etc/pacman.conf')


class ProvidedDependency(DataType):
    name: str
    package: pyalpm.Package
    version_matcher: VersionMatcher

    def __repr__(self) -> str:
        return (
            f'<{self.__class__.__name__} "{self.name}" '
            f'{self.version_matcher.line}>'
        )


def get_pkg_id(pkg: Union['AURPackageInfo', pyalpm.Package]) -> str:
    if isinstance(pkg, pyalpm.Package):
        return f"{pkg.db.name}/{pkg.name}"
    return f"aur/{pkg.name}"


DB_LOCK_REPO = Lock()
github actionless / pikaur / pikaur / install_cli.py View on Github external
return md5.hexdigest()


class InstallPackagesCLI():

    # User input
    args: PikaurArgs
    install_package_names: List[str]
    manually_excluded_packages_names: List[str]
    resolved_conflicts: List[List[str]]
    pkgbuilds_paths: List[str]

    # computed package lists:
    not_found_repo_pkgs_names: List[str]
    found_conflicts: Dict[str, List[str]]
    repo_packages_by_name: Dict[str, pyalpm.Package]
    aur_deps_relations: Dict[str, List[str]]
    extra_aur_build_deps: List[str]
    # pkgbuilds from cloned aur repos:
    package_builds_by_name: Dict[str, PackageBuild]

    # Packages' install info
    install_info: InstallInfoFetcher

    # Installation results
    # transactions by PackageSource(AUR/repo), direction(removed/installed):
    transactions: Dict[str, Dict[str, List[str]]]
    # AUR packages which failed to build:
    # @TODO: refactor to store in transactions
    failed_to_build_package_names: List[str]

    # arch news