Hacked By AnonymousFox

Current Path : /usr/lib/python3.6/site-packages/dnf/cli/commands/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/cli/commands/__pycache__/repoquery.cpython-36.pyc

3

�ft`ن�
@sddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZejd�Zd	Ze
jd
�ZdZdd
dddddddd�	Zdd�ZGdd�de	j�ZGdd�dej�ZGdd�de �Z!dS)�)�absolute_import)�print_function)�unicode_literals)�_)�commands)�OptionParserN�dnfz.%{name}-%{epoch}:%{version}-%{release}.%{arch}z%(-?\d*?){([:.\w]+?)}aname, arch, epoch, version, release, reponame (repoid), from_repo, evr,
debug_name, source_name, source_debug_name,
installtime, buildtime, size, downloadsize, installsize,
provides, requires, obsoletes, conflicts, sourcerpm,
description, summary, license, url, reason�	conflicts�enhances�	obsoletes�provides�
recommends�requiresZrequires_pre�suggests�supplements)	r	r
rrr
rzrequires-prerrcCs�dd�}dd�}|jdd�jdd�}x tj�D]\}}|j||�}q.Wd	}d
}x>tj|�D]0}|||||j���7}|||�7}|j�}qZW||||d��7}|S)z:Convert a rpm like QUERYFMT to an python .format() string.cSs^|j�d}|j�d}|rJ|ddkr:d|dd�}nd|}d|}d|j�|dS)	Nr��-�>�<�:z{0.�})�groups�lower)ZmatchobjZfill�key�r�/usr/lib/python3.6/repoquery.py�fmt_replDszrpm2py_format.<locals>.fmt_replcSs|jdd�jdd�S)N�{z{{rz}})�replace)Ztxtrrr�bracketsOszrpm2py_format.<locals>.bracketsz\n�
z\t�	�rN)r�OPTS_MAPPING�items�
QFORMAT_MATCH�finditer�start�end)�queryformatrrr�valueZfmt�spos�itemrrr�
rpm2py_formatBsr-c@seZdZdZdS)�_CommaSplitCallbackz\s*,\s*N)�__name__�
__module__�__qualname__ZSPLITTERrrrrr._sr.c@s�eZdZdZejejejd�Zd%e	ej
��Zed�Z
edd��Zedd	��Zd
d�Zdd
�Zdd�Zdd�Zd&dd�Zd'dd�Zd(dd�Zdd�Zdd�Zdd�Zd d!�Zd*d#d$�ZdS)+�RepoQueryCommandzSA class containing methods needed by the cli to execute the repoquery command.
    )zrepoquery-nzrepoquery-nazrepoquery-nevra�	repoquery�rqz$search for packages matching keywordcCs,|jr|j|jd�|jr(|j|jd�|S)z'Filter query by repoid and arch options)Zreponame)�arch)Zrepo�filterm�arches)�opts�queryrrr�filter_repo_archms
z!RepoQueryCommand.filter_repo_archc
Cs�|jddddtd�d�|jddtd�d	�|jd
ddgtd
td�d�|jddddtd�d�|jdgtdtd�d�|jdgtdtd�d�|jdgtdtd�d�|jdgtdtd�d�|jd gtdtd!�d�|jd"gtdtd#�d�|jd$gtdtd%�d�|jd&gtdtd'�d�|jd(gtdtd)�d�|j�}|jd*dtd+�d	�|jd,dtd-�d	�|jd.dtd/�d	�|jd0dtd1�d	�|jd2dtd3�d	�|jd4dtd5�d	�|jd6dtd7�d	�|jd8d9ttd:�d;�|jd<dtd=�d	�|j�}|jd>d?d@dAdtdB�dC�|jdDdEdFdAdtdG�dC�|jdHdIdJdAdtdK�dC�|jdLdMdAdtdN�dC�|jdOdPdQttdR�dS�|jdTdtdU�d	�|jdVdQtdWtdX�dY�|jdZdQd[dWtd\�dY�|jd]dQd^dWtd_�dY�|jd`dtda�d	�|j�}|jdbdcdddWtde�dY�|jdfdcdddWtjdY�|jdgdcdhdWtdi�dY�|jdjdcdkdWtdl�dY�|jdmdtdn�d	�|j�}tdo�tdp�tdq�tdr�tds�tdt�tdu�tdv�tdw�dx�	}x2|j�D]&\}}dy|}|j|dzdW||d{��q�W|jd|dtd}�d	�td~�td�td��td��j	t
jjd��td��d��}	|j�}
x2|	j�D]&\}}dy|}
|
j|
d�dW||d{��q4W|
jd�d�dWd�tjd{�|jd�dtd��d	�|jd�d�d�td��d��dS)�Nz-az--allZqueryall�
store_truezNQuery all packages (shorthand for repoquery '*' or repoquery without argument))�dest�action�helpz--show-duplicatesz(Query all versions of packages (default))r=r>z--archz
--archlistr7z[arch]z show only results from this ARCH)r<�defaultr=�metavarr>z-fz--file�FILE�+z show only results that owns FILE)r@�nargsr>z--whatconflictsZREQz#show only results that conflict REQ)r?r=r@r>z
--whatdependszishows results that requires, suggests, supplements, enhances,or recommends package provides and files REQz--whatobsoletesz#show only results that obsolete REQz--whatprovidesz"show only results that provide REQz--whatrequiresz:shows results that requires package provides and files REQz--whatrecommendsz$show only results that recommend REQz--whatenhancesz"show only results that enhance REQz--whatsuggestsz"show only results that suggest REQz--whatsupplementsz%show only results that supplement REQz	--alldepsz=check non-explicit dependencies (files and Provides); defaultz--exactdepsz:check dependencies exactly as given, opposite of --alldepsz--recursivezOused with --whatrequires, and --requires --resolve, query packages recursively.z	--deplistz>show a list of all dependencies and what packages provide themz	--resolvez.resolve capabilities to originating package(s)z--treez"show recursive tree for package(s)z--srpmz#operate on corresponding source RPMz--latest-limit�latest_limitzOshow N latest packages for a given name.arch (or latest but N if N is negative))r<�typer>z--disable-modular-filteringz-list also packages of inactive module streamsz-iz--info�	queryinfoFz+show detailed information about the package)r<r?r=r>z-lz--list�
queryfilelistz!show list of files in the packagez-sz--source�querysourcerpmzshow package source RPM namez--changelogs�querychangelogszshow changelogs of the packagez--qfz
--queryformatr)zfdisplay format for listing packages: "%%{name} %%{version} ...", use --querytags to view full tag list)r<r?r>z--querytagsz-show available tags to use with --queryformatz--nevra�store_constzZuse name-epoch:version-release.architecture format for displaying found packages (default))r<�constr=r>z--nvrz%{name}-%{version}-%{release}zQuse name-version-release format for displaying found packages (rpm query default)z--envraz.%{epoch}:%{name}-%{version}-%{release}.%{arch}zPuse epoch:name-version-release.architecture format for displaying found packagesz
--groupmemberz=Display in which comps groups are presented selected packagesz--duplicates�	pkgfilter�
duplicatedz/limit the query to installed duplicate packagesz--duplicatedz
--installonly�installonlyz1limit the query to installed installonly packagesz
--unsatisfied�unsatisfiedzClimit the query to installed packages with unsatisfied dependenciesz
--locationz5show a location from where packages can be downloadedz5Display capabilities that the package conflicts with.zaDisplay capabilities that the package can depend on, enhance, recommend, suggest, and supplement.z2Display capabilities that the package can enhance.z-Display capabilities provided by the package.z1Display capabilities that the package recommends.z1Display capabilities that the package depends on.z�If the package is not installed display capabilities that it depends on for running %%pre and %%post scriptlets. If the package is installed display capabilities that is depends for %%pre, %%post, %%preun and %%postun.z/Display capabilities that the package suggests.z5Display capabilities that the package can supplement.)	r	�dependsr
rr
rzrequires-prerrz--%s�
packageatr)r<r=rKr>z--availablez Display only available packages.z Display only installed packages.zLDisplay only packages that are not present in any of available repositories.zQDisplay only packages that provide an upgrade for some already installed package.zIDisplay only packages that can be removed by "{prog} autoremove" command.)�progz2Display only packages that were installed by user.)�	installedZextrasZupgrades�unneeded�
userinstalled�listz--autoremoverTz--recentz%Display only recently edited packagesr�*ZKEYzthe key to search for)rCr@r>)
�add_argumentrr.Zadd_mutually_exclusive_group�int�QFORMAT_DEFAULT�argparseZSUPPRESSr$�formatr�util�	MAIN_PROG)�parserZwhatrequiresformZoutformrLZpackage_attributeZ	help_msgs�argZhelp_msg�nameZ	help_listZ
list_groupZlist_argZhelp_argZswitchrrr�
set_argparservs


























zRepoQueryCommand.set_argparsercCs |jjs|jjtjtjd�dS)N)�stdout�stderr)r8�quiet�cliZredirect_logger�loggingZWARNING�INFO)�selfrrr�
pre_configureszRepoQueryCommand.pre_configurecCsj|jjs|jj�|jj}|jjrJ|jjrB|jjdd|jj�nd|j_|jjrVdS|jj	rx|jjrxt
jjtd���|jj
r�|jjr�|jjdd�t|jj|jjdko�|jj	g�s�t
jjtd���|jjs�|jj�r|jjp�|jj�st
jjtd	j|jj�rd
nd����|jj�r$|jjj�|jjdk�r@|jjd
k�sJ|jj�rPd|_d|_|jj�rfd|_dS)Nz--obsoletesz--rz�Option '--resolve' has to be used together with one of the '--conflicts', '--depends', '--enhances', '--provides', '--recommends', '--requires', '--requires-pre', '--suggests' or '--supplements' optionsz--recursivez--exactdepsrz�Option '--recursive' has to be used with '--whatrequires <REQ>' (optionally with '--alldeps', but not with '--exactdeps'), or with '--requires <REQ> --resolve'z;argument {} requires --whatrequires or --whatdepends optionz	--alldepsrSrUrNT)rSrU)r8rerfZredirect_repo_progress�demandsrrQZ_option_conflict�	querytags�resolverZCliErrorr�	recursive�	exactdeps�any�whatrequires�alldeps�whatdependsr\�srpm�baseZreposZenable_source_reposrVrL�	availableZavailable_reposZsack_activationrI�
changelogs)rirkrrr�	configures@




zRepoQueryCommand.configurec	Cs|jrpg}|jdt|��xH|jD]>}|d}|jd|jd�tjj|d�tjj|d�f�q$Wdj|�Syht	|�}|j
r�|jjj
|�S|jr�|j}|s�ttd�j|�tjd	�|S|jr�|jSt|j�j|�SWn4tk
�r}ztjjt|���WYdd}~XnXdS)
NzChangelog for %s�	timestampz* %s %s
%s
z%a %b %d %YZauthor�textr zPackage {} contains no files)�file)rI�append�strrw�strftimer�i18n�ucd�join�PackageWrapperrFru�outputZ
infoOutputrG�files�printrr\�sysrdrHZ	sourcerpmr-r)�AttributeError�
exceptions�Error)	rir8�pkg�outZchlog�dtZpoZfilelist�errr�build_format_fnGs.
z RepoQueryCommand.build_format_fncCsN|jjj�jdd�}x4|D],}|j|jtjj|�j	|jjddd���}qW|S)NT)�emptyF)�
with_providesZwith_filenames)
ru�sackr9r6�union�intersectionr�subject�Subject�get_best_query)riZnevrasZ
base_query�resolved_nevras_queryZnevrarrr�_resolve_nevrascs
z RepoQueryCommand._resolve_nevrasNcCsD|r|n|}|j|d�}|j|�}|j|�}|r@|j|||d�}|S)N)r)�done)�filter�
differencer��_do_recursive_deps)ri�query_in�query_selectr�Zquery_requiredrrrr�ps

z#RepoQueryCommand._do_recursive_depsFcCs�|j||�}|j|d�}|j|j|d��}|r�|j|j|d��}|j|j|d��}|j|j|d��}|j|j|d��}|j|j|d��}|j|j|d��}|j|j|d	��}|j|j|d
��}|jjr�|j||�}|S)N)�requires__glob)r)�recommends__glob)�enhances__glob)�supplements__glob)�suggests__glob)r
)r
)r)r)r�r�r�r8rnr�)ri�namesr9Z
all_dep_typesr�Zdepqueryrrr�by_all_deps}szRepoQueryCommand.by_all_depscCs�|r|n|jjj�jdd�}|jjj�jdd�}x$|j�D]}|j|j|jd��}q:W|j|�}|rz|j	|||j|�d�}|j|�S)NT)r�)r)r�)
rur�r9r6�runr�r�rr��_get_recursive_providers_query)rir��	providersr��tr�r�rrrr��s
z/RepoQueryCommand._get_recursive_providers_querycCsxg}g}xN|jjD]B}tjjj|�d}|jd�r>|j|�q|r|d	kr|j|�qW|rt|jj|d|jj	j
d�}|S)
Nrz.rpm�http�ftpr{�httpsF)�strict�progress)r�r�r{r�)r8rrZpycompZurlparse�endswithr|ruZadd_remote_rpmsr�r�)riZrpmnames�remote_packagesrZschemesrrr�_add_add_remote_packages�s
z)RepoQueryCommand._add_add_remote_packagesc	Cs�|jjrtt�dS|jj|j�|jjj|jj	r8t
jnt
jd�}|jj
r�|j�}i}|jj|jkrx|j|jjg|d<g}|jdd�}|r�|j|jjj�j|d��}x>|jj
D]2}|jtjj|dd�j|jjfd|d�|���}q�W|}|jj�r|j|jjj�}|jj�rX|jj�r�|jjd	k�r�t|jjj��tjj t!d
j"dd|jj����nH|jjd
k�rx|j#|jj$j%�}n(|jj�r�|jjdk�r�t&||jj��}|jj'dk�r�|jj(|�}|j)|�j*�}n�|jj'dk�r�|jj(|�}n�|jj'dk�rVtjj+|j�}|j,|jjj-|jjj.�tj/j0|�}	d|	_1|	j2dd�}
|
�sRttj3j4|	j5���dS|jj�sh|j�}|j6|j|�}|}|jj7�r�|j|jj7d�|jj8�r�|j|jj8d�}|j|j|j9|jj8|�d��}|jj:�r�|j|jj:d�|jj;�r|j|jj;d�}
|
�r|
}n|j|jj;d�|jj<�rR|jj=�rB|j|jj<d�n|j>|jj<|�}|jj?�r�|jj=�r�|j|jj?d�}|j|j|jj?d��}|j|j|jj?d��}|j|j|jj?d��}|j|j|jj?d��}n|j>|jj?|d�}|jj@�r|j|jj@d�}|j|j|j9|jj@|�d��}|jjA�rR|j|jjAd�}|j|j|j9|jjA|�d��}|jjB�r�|j|jjBd�}|j|j|j9|jjB|�d��}|jjC�r�|j|jjCd�}|j|j|j9|jjC|�d ��}|jjD�r�|jE|jjD�}|jjF|dd!�}|jjG�rRg}xD|D]<}|jH}|dk	�r�|jjj�j||jId"d#�}||j2�7}�q�W|jjj�j|d�}|jjJ�r�|jj<�r�|jjKd9k�r�tjj t!d,�j"tj3jLd-���|jM|||j�dStN�}|jjK�r�tN�}x||j2�D]p}|jjdk�s�|jj$jO|��r�|jjKd.k�r|jP|jQ|jR|jS|jT|jU�n|jPt&|tV|jjK���q�W|jjW�r�|jjd	k�rj|j6|j|jjj��}n|j6|j|jjj�j��}|j|d/�}|jjX�r�|j|jY||��}tN�}x@|jE�j2�D]}|jZ|j[|j|���q�Wn|jPd0d1�|D���n�|jj\�r6x.|j2�D]"}|j]�}|dk	�r|jZ|��qW�nv|jj^�rNg}x�t_tN|j2���D]�}|jjdk�sx|jj$jO|��rVg}|j`d2ta|��x�t_d3d4�|jQD��D]x}|j`d5|�tjj|�}|j|jj�}|j6|j|j��}|jjb�s�|jE�}x$|j2�D]}|j`d6ta|���q�W�q�W|j`d7jc|���qVW|�rJtd8jc|��dS|jjd�rf|je|�dSxD|j2�D]8}|jjdk�s�|jj$jO|��rp|jZ|j[|j|���qpW|�r�|jjf�r�td8jct_|���ntd7jct_|���dS):N)�flagsZformsT)r�)r�)Zignore_caseF)r�r9rSz)argument {}: not allowed with argument {}z--availablez--rTrUrMrNrO)Zverify)Z
file__glob)Zconflicts__glob)r	)r)Zprovides__glob)r�)r�)r�)r�)r�)r
)r
)r)r)Zwarning�src)ra�evrr5r	r
rrr
rrrz�No valid switch specified
usage: {prog} repoquery [--conflicts|--enhances|--obsoletes|--provides|--recommends|--requires|--suggest|--supplements|--whatrequires] [key] [--tree]

description:
  For the given packages print a tree of thepackages.)rRrP)rcss|]}t|�VqdS)N)r})�.0Zrelrrr�	<genexpr>Qsz'RepoQueryCommand.run.<locals>.<genexpr>z	package: cSsg|]}t|��qSr)r})r��reqrrr�
<listcomp>]sz(RepoQueryCommand.run.<locals>.<listcomp>z  dependency: z
   provider: r z

)r	r
rrr
rrr)gr8rlr��
QUERY_TAGSrfZ _populate_update_security_filterrur�r9Zdisable_modular_filtering�hawkeyZIGNORE_MODULAR_EXCLUDESZAPPLY_EXCLUDESrr�Zcommand�nevra_formsr�r�r6rr�r�r�ZrecentZ_recentZconfrvrVZ	optparserZprint_usager�r�rr\Z	_unneeded�historyZswdb�getattrrLZ_get_installonly_queryr�rMZ
rpmdb_sackZ
_configureZinstallonlypkgsZinstallonly_limit�goalZGoalZprotect_running_kernelr�r]Z_format_resolve_problemsZ
problem_rulesr:r{Z
whatconflictsr�Z
whatobsoletesZwhatprovidesrqror�rsZwhatrecommendsZwhatenhancesZwhatsupplementsZwhatsuggestsrDZlatestZ_merge_update_filtersrtZsource_namer�ZtreerQr^�	tree_seed�setZuser_installed�updaterr
rrr
r#rmrnr��addr��locationZremote_locationZdeplist�sortedr|r}�verboser�Zgroupmember�_group_member_reportrF)ri�qr�ZkwarkZpkgsZ
query_resultsrrNZrpmdbr�ZsolvedZorqueryZrelsZquery_for_provideZdependsqueryZpkg_listr�ZsrcnameZ	tmp_queryr9r�r�Zdeplist_outputr�r�Zproviderrrrr��sH





















"








zRepoQueryCommand.runc
Cs&i}x.|jjjD] }tdd�|j�D��||j<qWi}g}xr|j�D]f}g}x(|j�D]\}}	|j|	krX|j	|�qXW|r�|j
djt|��g�j	t
|��qF|j	t
|��qFWg}
xDt|j��D]4\}}|
j	djt|�tdd�|jd�D����q�W|
j	djt|���|
�r"tdj|
��dS)NcSsg|]
}|j�qSr)ra)r�r�rrrr�}sz9RepoQueryCommand._group_member_report.<locals>.<listcomp>�$r cSsg|]}d|�qS)z  @r)r��idrrrr��s)ru�compsrr�Z
packages_iterr�r�r$rar|�
setdefaultr�r�r}�splitr�)
rir9Zpackage_conf_dict�groupZgroup_package_dictZpkg_not_in_groupr�Z
group_id_listZgroup_idZpackage_name_setr�rZpackage_listrrrr�zs* 
,z%RepoQueryCommand._group_member_reportc
Cs�|j||�}|d
kr t|�dSd}xtd|�D]}|d7}q0Wg}x|jD]}|jt|��qLWdtt|��ddj|�d}	t|d	|d|	�dS)Nr� rz|   �[z: z, �]z\_ ���)r�r��rangerr|r}�lenr�)
ri�levelr�r8Z
pkg_stringZspacing�xrZ
requirepkgZreqstrrrr�	grow_tree�s"zRepoQueryCommand.grow_treercCs8�x0tt|j��dd�d�D�]}|dks2|dkr8t�n|}|jjd�sT|jjd�rXdS|j|||�||kr|j|�|jr�t||j�}i}xFt|�D]:}	|j	j
j�j|	d�}
x |
D]}|||jd|j
<q�Wq�W|j	j
j�jt|j��d	�}
n&|j�r|j|jf|�n|j|jd
�}
|j|
|||d|�qWdS)NcSs|jS)N)ra)�prrr�<lambda>�sz,RepoQueryCommand.tree_seed.<locals>.<lambda>)rrZrpmlibZsolvable)r�.)r�)r�r�)r�r�r�ra�
startswithr�r�rQr�rur�r9r6r5rV�valuesrrr�r�r�)rir9Zaqueryr8r�Zusedpkgsr�Zstrpkg�arraZpkgqueryZquerypkgrrrr��s$"

zRepoQueryCommand.tree_seed)r3r4)N)F)Nr�)r�N)r/r0r1�__doc__r�Z	FORM_NAMEZFORM_NAZ
FORM_NEVRAr��tuple�keys�aliasesrZsummary�staticmethodr:rbrjrxr�r�r�r�r�r�r�r�r�r�rrrrr2cs,
	0



Hr2c@sDeZdZdZdd�Zdd�Zedd��Zedd	��Z	ed
d��Z
dS)
r�z>Wrapper for dnf.package.Package, so we can control formatting.cCs
||_dS)N)�_pkg)rir�rrr�__init__�szPackageWrapper.__init__cCsFt|j|�}|dkrdSt|t�r:djtdd�|D���Stjj|�S)Nz(none)r cSsh|]}tjj|��qSr)rrr�)r�Zreldeprrr�	<setcomp>�sz-PackageWrapper.__getattr__.<locals>.<setcomp>)	r�r��
isinstancerVr�r�rrr�)ri�attrZatrrrr�__getattr__�s
zPackageWrapper.__getattr__cCs&|dkrtjj|�}|jd�SdSdS)Nrz%Y-%m-%d %H:%Mr")�datetimeZutcfromtimestampr~)ryr�rrr�_get_timestamp�s
zPackageWrapper._get_timestampcCs|j|jj�S)N)r�r��	buildtime)rirrrr��szPackageWrapper.buildtimecCs|j|jj�S)N)r�r��installtime)rirrrr��szPackageWrapper.installtimeN)r/r0r1r�r�r�r�r��propertyr�r�rrrrr��sr�)"Z
__future__rrrZdnf.i18nrZdnf.clirZdnf.cli.option_parserrr[r�rg�rer�rZdnf.exceptionsZdnf.subjectZdnf.utilr�Z	getLoggerZloggerrZ�compiler%r�r#r-Z_SplitCallbackr.ZCommandr2�objectr�rrrr�<module>sJ

W

Hacked By AnonymousFox1.0, Coded By AnonymousFox