MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python2.7/site-packages/dnf/yum/misc.pyo
�
�[/\c@@sTdZddlmZmZddlmZddlmZddlmZm	Z	m
Z
ddlTddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZedd	d
ddg�Zd
gZda!d
�Z"da#d�Z$de%fd��YZ&d�Z'd%dd�Z(de%fd��YZ)d�Z*d�Z+de,d�Z-d�Z.d�Z/d�Z0d�Z1e2d�Z3d�Z4da5d �Z6de2e2d!�Z7d"�Z8e2d#�Z9e,d$�Z:dS(&u%
Assorted utility functions for yum.
i(tprint_functiontabsolute_import(tunicode_literals(t	MiscError(tbase64_decodebytest
basestringtunicode(t*Numd5usha1usha256usha384usha512cC@s+tdkr!tjd�jant|�S(u( Tests if a string is a shell wildcard. u[*?]|\[.+\]N(t_re_compiled_glob_matchtNonetretcompiletsearch(ts((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytre_glob3scC@sdtdkr?tjd�j}tjd�j}||fanxtD]}||�rFtSqFWtS(uC Tests if a string needs a full nevra match, instead of just name. u.*([-.*?]|\[.+\]).u[0-9]+:N(t_re_compiled_full_matchR	R
RtmatchtTruetFalse(R
tonettwotrec((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytre_full_search_needed;s
t	ChecksumscB@szeZdZd
eed�Zd�Zedd��Zd�Z	dd�Z
d	�Zd
d
�Zd�Z
d
d�ZRS(un Generate checksum(s), on given pieces of data. Producing the
        Length and the result(s) when complete. cC@s�|dkrt}ng|_g|_d|_t�}x�|D]�}|dkr[d}n||krmq@n|tkr�tj|�}n|r�q@nt	d|��|j
|�|jj|�|jj|�q@W|r�|r�t	d��ndS(Niushausha1u(Error Checksumming, bad checksum type %su*Error Checksumming, no valid checksum type(R	t_default_checksumst	_sumalgost	_sumtypest_lentsett_available_checksumsthashlibtnewRtaddtappend(tselft	checksumstignore_missingtignore_nonetdonetsumtypetsumalgo((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt__init__Ns,					
	

cC@s|jS(N(R(R"((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt__len__istfgetcC@s|jS(N(R(R"((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt<lambda>mscC@s^|jt|�7_xB|jD]7}t|t�rC|jd�n|}|j|�qWdS(Nuutf-8(RtlenRt
isinstanceRtencodetupdate(R"tdataR(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR0os$iicC@s |j|�}|j|�|S(N(treadR0(R"tfotsizeR1((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR2us
cC@s@i}x3t|j|j�D]\}}|j�||<qW|S(N(tzipRRt	hexdigest(R"tretR'tsumdata((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt
hexdigestszs"cC@sL|dkr)|jsdS|jd}n|dkr>d}n|j�|S(Niushausha1(R	RR9(R"tchecksum((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR6�s		cC@s@i}x3t|j|j�D]\}}|j�||<qW|S(N(R5RRtdigest(R"R7R'R8((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytdigests�s"cC@sL|dkr)|jsdS|jd}n|dkr>d}n|j�|S(Niushausha1(R	RR<(R"R:((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR;�s		Ni(t__name__t
__module__t__doc__R	RR)R*tpropertytlengthR0R2R9R6R<R;(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyRJs					cC@stdS(Ni(R(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytget_default_chksum_type�siic	C@s(t|t�rny2t|d|��}t||||�SWdQXWqnttfk
rjtd|��qnXny�t|g�}x5|j||�r�|dk	r�|j
|kr�Pq�q�W|dk	r�||j
kr�d||j|�fS|j|�SWn)ttfk
r#}td|��nXdS(u�takes filename, hand back Checksum of it
       sumtype = md5 or sha/sha1/sha256/sha512 (note sha == sha1)
       filename = /path/to/file
       CHUNK=65536 by defaulturbNu#Error opening file for checksum: %su!%u!%su#Error reading file for checksum: %s(R.RtopenR:tIOErrortOSErrorRRR2R	RAR6(R'tfiletCHUNKtdatasizeR3R1te((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR:�s t
GenericHoldercB@s>eZdZdd�Zd�Zd�Zd�Zd�ZRS(u�Generic Holder class used to hold other objects of known types
       It exists purely to be able to do object.somestuff, object.someotherstuff
       or object[key] and pass object to another function that will
       understand itcC@s
||_dS(N(t_GenericHolder__iter(R"titer((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyR)�scC@s$|jdk	r t||j�SdS(N(RKR	RL(R"((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt__iter__�scC@s,t||�rt||�St|��dS(N(thasattrtgetattrtKeyError(R"titem((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt__getitem__�s
cC@sd�t|�j�D�S(u!Return a dictionary of all lists.cS@s1i|]'\}}t|�tkr||�qS((ttypetlist(t.0tkeytlist_((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pys
<dictcomp>�s		(tvarstitems(R"((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt	all_lists�scC@sFx?|j�j�D]+\}}t|�j|g�j|�qW|S(u7 Concatenate the list attributes from 'other' to ours. (RZRYRXt
setdefaulttextend(R"totherRVtval((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytmerge_lists�s#N(	R=R>R?R	R)RMRRRZR_(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyRJ�s			cC@s�tjdd|�}tj�}d}d}x�|jd�D]�}|jd�r[d}q=|r||j�dkr|d}q=|r�|jd�r�Pq=|r�|jd�r�Pq=|r=|j|d�q=q=Wt|j	��S(	u-Convert ASCII armoured GPG key to binary
    s
?s
is$-----BEGIN PGP PUBLIC KEY BLOCK-----its"-----END PGP PUBLIC KEY BLOCK-----t=(
R
tsubtiotBytesIOtsplitt
startswithtstriptwriteRtgetvalue(trawkeytblocktinblocktpastheaderstline((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt
procgpgkey�s 		cC@skxd|jdd�D]P}|d|krt|dd�}||krLdS||kr\dSdSqqWd	S(
ub
    Return if the GPG key described by the given keyid and timestamp are
    installed in the rpmdb.

    The keyid and timestamp should both be passed as integers.
    The ts is an rpm transaction set object

    Return values:
        - -1      key is not installed
        - 0       key with matching ID and timestamp is installed
        - 1       key with matching ID is installed but has an older timestamp
        - 2       key with matching ID is installed but has a newer timestamp

    No effort is made to handle duplicates. The first matching keyid is used to
    calculate the return result.
    unameu
gpg-pubkeyuversionureleaseiiiii����(tdbMatchtint(ttstkeyidt	timestampthdrtinstalledts((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytkeyInstalled�scC@srtjj|�s"tj|�ntjj|��8tjj��"}ttjj	|d�d��}|j
d�WdQX|j|�|r^|d}tjj|�s^tj|dd�x[tj|d�D]F}tjj
|�}|d|}	tj||	�tj|	d�q�Wd	}
ttjj	|d�d
d��}|j
|
�WdQXq^ntSWdQXWdQXdS(Nugpg.confuwbR`u-rotmodei�u/*u/u�lock-never
    no-auto-check-trustdb
    trust-model direct
    no-expensive-trust-checks
    no-permission-warning
    preserve-permissions
    uw(tostpathtexiststmakedirstdnftcryptotpubring_dirtContextRCtjoinRht	op_importtglobtbasenametshutiltcopytchmodR(RjRstgpgdirtmake_ro_copytctxtfptrodirtfR�tro_ftopts((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytimport_key_to_pubrings(!

$c	C@stj�}y?tj|�}tjj|d�}dtjj|f}Wn't	k
rtdtjj|f}nXdtjj
|f}ttj|��}xW|D]O}tj
|�}t|d�r�t|d�dkr�|d|kr�|Sq�Wtjd|dtjj
�}|S(uqreturn a path to a valid and safe cachedir - only used when not running
       as root or when --tempcache is setiu%s-%s-u%s/%s*i�itprefixtdir(RytgeteuidtpwdtgetpwuidR}ti18ntucdtconsttPREFIXRPtTMPDIRtsortedR�tlstattS_ISDIRtS_IMODEttempfiletmkdtemp(	tuidtusertuptusernameR�tdirpatht	cachedirstthisdirtstatstcachedir((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytgetCacheDir7s

6cC@s|dkr!tj|d�}nB|dkrBtj|d�}n!|dkrctj|d�}nt|d�}x�try|jd�}Wnt	k
r�PnX|s�Pny|j
|�Wqutt	fk
r}d|t|�f}t
jj|��quXquW|j�|j�dS(Nubz2uruxzugzuwbi�uError writing to file %s: %s(tbz2tBZ2FiletlzmatLZMAFiletgziptGzipFileRCRR2RDRhREtstrR}t
exceptionsRtclose(tsourcetdesttztypets_fntdestinationR1RItmsg((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt_decompress_chunkedOs*	

cC@s~g}t|�}t|�}d}xB||krh||}|j|||!�||7}||8}q'W|j||�|S(uE Given a seq, split into a list of lists of length max_entries each. i(R-RTR!(tseqtmax_entriesR7tnumtbegtend((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt
seq_max_splitks

cC@sCytj|�Wn+tk
r>}|jtjkr?�q?nXdS(u| Call os.unlink, but don't die if the file isn't there. This is the main
        difference between "rm -f" and plain "rm". N(RytunlinkREterrnotENOENT(tfilenameRI((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytunlink_fys
cC@siytj|�SWnQtk
rd}|jtjtjfkrBdS|r^|jtjkr^dS�nXdS(uF Call os.stat(), but don't die if the file isn't there. Returns None. N(RytstatRER�R�tENOTDIRR	tEACCES(R�t
ignore_EACCESRI((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytstat_f�scC@sTy/td��}|j�}t|�SWdQXWnttfk
rOtj�SXdS(u� Get the audit-uid/login-uid, if available. os.getuid() is returned
        instead if there was a problem. Note that no caching is done here. u/proc/self/loginuidN(RCR2RqRDt
ValueErrorRytgetuid(R3R1((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt_getloginuid�scC@stdkrt�antS(u� Get the audit-uid/login-uid, if available. os.getuid() is returned
        instead if there was a problem. The value is cached, so you don't
        have to save it. N(t_cached_getloginuidR	R�(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytgetloginuid�sc	C@s|}|s|}n|jd�rHd}|s�|jdd�}q�n�|jd�sf|jd�r�d}|s�|jd�r�|jdd�}q�|jdd�}q�n?|jd�r�d}|s�|jdd�}q�n|}d	}|r{|r{|r=t|�}t|�}|r=|r=|j|jkr=|Snt|||�|r{|r{tj||j|jf�q{n|S(
u|take a filename and decompress it into the same relative location.
       if the file is not compressed just return the fileu.gzugzuu.bzu.bz2ubz2u.xzuxzN(tendswithtreplaceR	R�tst_mtimeR�Rytutime(R�R�tfn_onlytcheck_timestampstoutR�tfiR3((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt
decompress�s:	
"cC@sPtjj|�}|d7}tjj|�sDtj|dd�n|d|S(Nu/genRxi�u/(RyRztdirnameR{R|(R�tgenerated_nameR�((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytcalculate_repo_gen_dest�s

cC@s+t||�}t|d|dtd|�S(u� This is a wrapper around decompress, where we work out a cached
        generated name, and use check_timestamps. filename _must_ be from
        a repo. and generated_name is the type of the file. R�R�R�(R�R�R(R�R�tcachedR�((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytrepo_gen_decompress�sc	C@s�g}x�tj|�D]�}t|���}x�|D]�}tjd|�rPq2n|j�}|j�}|stq2n|r�|jdd�}|jdd�}|j|j��q2n|j	|�q2WWdQXqW|S(u( Takes a glob of a dir (like /etc/foo.d/\*.foo) returns a list of all
       the lines in all the files matching that glob, ignores comments and blank
       lines, optional paramater 'line_as_list tells whether to treat each line
       as a space or comma-separated list, defaults to True.
    u\s*(#|$)u
u u,N(
R�RCR
RtrstriptlstripR�R\ReR!(tthisglobtline_as_listtresultstfnameR�Rn((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pytread_in_items_from_dot_dir�s"
i(;R?t
__future__RRRtdnf.exceptionsRt
dnf.pycompRRRR�R�t	dnf.constR}t
dnf.cryptotdnf.i18nR�R�R�RRcR�Rytos.pathR�R
R�R�RRRR	RRRRtobjectRRBR:RJRoRwRR�R�R�R�R�RR�R�R�R�R�R�R�R�(((s0/usr/lib/python2.7/site-packages/dnf/yum/misc.pyt<module>s^
			N			#								+