Source code for pkgbuilder.utils

# -*- encoding: utf-8 -*-
# PKGBUILDer v4.2.18
# An AUR helper (and library) in Python 3.
# Copyright © 2011-2018, Chris Warrick.
# See /LICENSE for licensing information.

"""
Common global utilities, used mainly for AUR data access.

:Copyright: © 2011-2018, Chris Warrick.
:License: BSD (see /LICENSE).
"""

import os
from . import DS, _
from .aur import AUR
from .package import AURPackage
from .ui import get_termwidth, hanging_indent, mlist
from pkgbuilder.exceptions import SanityError, AURError
import pyalpm
import textwrap

__all__ = ('info', 'search', 'msearch', 'print_package_search',
           'print_package_info',)
RPC = AUR()


[docs]def info(pkgnames): """Return info about AUR packages. .. versionchanged:: 3.0.0 """ if isinstance(pkgnames, str): pkgnames = [pkgnames] aur_pkgs = RPC.multiinfo(pkgnames) if aur_pkgs['type'] == 'error': raise AURError(aur_pkgs['error']) else: return [AURPackage.from_aurdict(d) for d in aur_pkgs['results']]
[docs]def msearch(maintainer): """Search for AUR packages maintained by a specified user. .. versionadded:: 3.0.0 """ aur_pkgs = RPC.search('maintainer', maintainer) if aur_pkgs['type'] == 'error': raise AURError(aur_pkgs['error']) else: return [AURPackage.from_aurdict(d) for d in aur_pkgs['results']]