KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/lib/python2.4/site-packages/yum/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/lib/python2.4/site-packages/yum/misc.pyo
m
Pc@sdZdkZdkZdkZdklZdkZdkZdkZdk	Z	dk
Z
dkZdkZdk
Z
dkZdkZdkTydkZdkZWnej
o
dZnXy(dkZddddgZdgZWnMej
oAdkZdkZddgZdgZdfd	YZnXd
klZdklZlZlZha ha!dZ"d
Z#da$dZ%da&dZ'da(dZ)da*dZ+dZ,dfdYZ-dfdYZ.dddZ/dZ0dfdYZ1dZ2e3dZ4dZ5d Z6ddd!Z7d"Z8dd#Z9d$e:d%Z;d&Z<d'Z=d(Z>d)Z?d*Z@d+ZAd,ZBd-d.ZCd-d/ZDd0ZEd1ZFe3d2ZGd3ZHdkIZIdkJZJe:e3d4ZKd5ZLdS(6s%
Assorted utility functions for yum.
N(sStringIO(t*tmd5tsha1tsha256tsha512thashlibcBstZedZRS(NcCsC|djotiSn|djotiSntddS(NRRsBad checksum type(talgoRtnewtshat
ValueError(R((t,/usr/lib/python2.4/site-packages/yum/misc.pyR%s


(t__name__t
__module__tstaticmethodR(((R
R#s(s	MiscError(sto_utf8s
to_unicodesto_strcCsNt}t|to
t}nt|tijo|Sn|i	||S(s Take a value and use the same value from the store,
        if the value isn't in the store this one becomes the shared version. N(
t_share_data_storetstoret
isinstancetvaluetunicodet_share_data_store_uttypettypest	TupleTypet
setdefault(RR((R
t
share_data5s
cCshahadS(N(RR(((R
tunshare_dataEscCs-tdjotidanti|S(s( Tests if a string is a shell wildcard. s.*[\*\?\[\]].*N(t_re_compiled_glob_matchtNonetretcompiletmatchts(R((R
tre_globLs

cCsztdjo@tid}tid}tid}|||fanx&tD]}|i|ot
SqTqTWtS(Ns	.*bin\/.*s
^\/etc\/.*s^\/usr\/lib\/sendmail$(t_re_compiled_pri_fnames_matchRRRtonettwotthreetrecRtfilenametTruetFalse(R&R#R"R$R%((R
tre_primary_filenameUs
cCshtdjo.tid}tid}||fanx&tD]}|i|ot	SqBqBWt
S(Ns	.*bin\/.*s
^\/etc\/.*(t_re_compiled_pri_dnames_matchRRRR"R#R%RtdirnameR'R((R+R#R"R%((R
tre_primary_dirnamebs
cCshtdjo.tid}tid}||fanx&tD]}|i|ot	SqBqBWt
S(sC Tests if a string needs a full nevra match, instead of just name. s.*[-\.\*\?\[\]].*.$s^[0-9]N(t_re_compiled_full_matchRRRR"R#R%RRR'R((RR#R"R%((R
tre_full_search_neededns
cCs)t|}|djogSnyt|}Wntj
onXt|Syt|}|iWntj
o
~nnX|d}d}}xM||jo?|||jo ||||<}|d7}n|d7}qW|| Sg}x,|D]$}||jo|i
|qqW|S(sReturn a list of the elements in s, but without duplicates.

    For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3],
    unique("abcabc") some permutation of ["a", "b", "c"], and
    unique(([1, 2], [2, 3], [1, 2])) some permutation of
    [[2, 3], [1, 2]].

    For best speed, all sequence elements should be hashable.  Then
    unique() will usually work in linear time.

    If not possible, the sequence elements should enjoy a total
    ordering, and if list(s).sort() doesn't raise TypeError it's
    assumed that they do enjoy a total ordering.  Then unique() will
    usually work in O(N*log2(N)) time.

    If that's not possible either, the sequence elements must support
    equality-testing.  Then unique() will usually work in quadratic
    time.
    iiN(tlenRtntsettut	TypeErrortlisttttsorttlasttlastititxtappend(RR7R9R8R0R2R5R:((R
tunique~s<

	



t	ChecksumscBsitZdZeedZdZdZdddZdZ	edZ
d	Zed
ZRS(sn Generate checksum(s), on given pieces of data. Producing the
        Length and the result(s) when complete. cCs|djo
t}ng|_g|_d|_t}x|D]}|djo
d}n||joqBn|t
joti|}n|oqBntd||i||ii||ii|qBW|p
tdndS(NiRRs(Error Checksumming, bad checksum type %ss*Error Checksumming, no valid checksum type(t	checksumsRt_default_checksumstselft	_sumalgost	_sumtypest_lenR1tdonetsumtypet_available_checksumsRRtsumalgotignore_missingt	MiscErrortaddR;(R@R>RHRERGRD((R
t__init__s,

				





cCs|iS(N(R@RC(R@((R
t__len__scCs:|it|7_x|iD]}|i|qWdS(N(R@RCR/tdataRARGtupdate(R@RMRG((R
RNs
iicCs |i|}|i||S(N(tfotreadtsizeRMR@RN(R@RORQRM((R
RPs
cCs@h}x3t|i|iD]\}}|i||<qW|S(N(trettzipR@RBRAREtsumdatat	hexdigest(R@RERRRT((R
t
hexdigestss
cCsC|djo|id}n|djo
d}n|i|S(NiRR(tchecksumRR@RBRV(R@RW((R
RUs



cCs@h}x3t|i|iD]\}}|i||<qW|S(N(RRRSR@RBRARERTtdigest(R@RERRRT((R
tdigestss
cCsC|djo|id}n|djo
d}n|i|S(NiRR(RWRR@RBRY(R@RW((R
RXs



(
RRt__doc__RR(RKRLRNRPRVRURYRX(((R
R=s				tAutoFileChecksumscBs/tZdZedZdZddZRS(sk Generate checksum(s), on given file/fileobject. Pretending to be a file
        object (overrrides read). cCs||_t|||_dS(N(ROR@t_foR=R>RH(R@ROR>RH((R
RK
s	cCst|i|S(N(tgetattrR@R\tattr(R@R^((R
t__getattr__sicCs|ii|i|S(N(R@R>RPR\RQ(R@RQ((R
RPs(RRRZR(RKR_RP(((R
R[s	iicCsyt|tijo
|}nt|d|}t|g}x|i
||oqGWt|tijo|i~n|i
|SWn(ttfj
o}td|nXdS(stakes filename, hand back Checksum of it
       sumtype = md5 or sha/sha1/sha256/sha512 (note sha == sha1)
       filename = /path/to/file
       CHUNK=65536 by defaulttrs#Error opening file for checksum: %sN(RtfileRtStringTypesROtopentCHUNKR=RERMRPt
StringTypetcloseRUtIOErrortOSErrorteRI(RERaRdRiRMRO((R
RWs

cCst|}yti|}Wn(tj
o}t	d||fnXx|D]}tii|d|ot|d|||}qQ||id|jo+tii|d|}|i|qQqQW|S(sfReturn all files in path matching ext, store them in filelist, 
       recurse dirs return list objects Error accessing directory %s, %st/s%sN(R/texttextlentostlistdirtpathtdir_listRhRiRItdtisdirtgetFileListtfilelisttlowertnormpathtnewpathR;(RoRkRtRlRwRiRqRp((R
Rs.st
GenericHoldercBstZdZdZRS(sGeneric 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 itcCs.t||ot||Sn
t|dS(N(thasattrR@titemR]tKeyError(R@Rz((R
t__getitem__Hs(RRRZR|(((R
RxBscCstidid|}t}d}d}x|idD]}|i
do
d}q@|o|idjo
d}q@|o|i
doPq@|o|i
doPq@|o|i|dq@q@Wt
i|iS(
s-Convert ASCII armoured GPG key to binary
    s(
|
|
)s
is$-----BEGIN PGP PUBLIC KEY BLOCK-----its"-----END PGP PUBLIC KEY BLOCK-----t=N(RRtsubtrawkeytStringIOtblocktinblocktpastheaderstsplittlinet
startswithtstriptwritetbase64tdecodestringtgetvalue(RRRRR((R
t
procgpgkeyNs$	

c
Csg}yti|}Wn'tj
o}tt|nXt	|djotdnx|D]}|ii}	hd|i<dtid|	d<d|ii<d|ii<d|i<}x|idD]}t|tipqn|i|	joPt|d	o<|iti}|djot|d
|d<PqdqhqqW|i|qmW|o|Sn	|dSdS(sReturn a dict of info for the given ASCII armoured key text

    Returned dict will have the following keys: 'userid', 'keyid', 'timestamp'

    Will raise ValueError if there was a problem decoding the key.
    isNo key found in given key datatuseridtkeyids>Qt	timestamptfingerprinttraw_keythashed_subpaksiN(!t
key_info_objstpgpmsgtdecode_multiple_keysRtkeyst	ExceptionRiR	tstrR/tkeyt
public_keytkey_idt
keyid_blobtuser_idtstructtunpackRRRtinfotuser_idsRRt	signatureRytget_hashed_subpaktSIG_SUB_TYPE_CREATE_TIMEttspktRtintR;tmultiple(
RRRRRRRRRiR((R
t
getgpgkeyinfoks4U

cCsd|d@S(s[Convert an integer representing a GPG key ID to the hex version string
    used by RPM
    s%08xlN(R(R((R
t
keyIdToRPMVerscCst|}xp|iddD]\}|d|joEt|dd}||jodSq{||jodSq{dSqqWd	S(sd
    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 a 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.
    tnames
gpg-pubkeytversiontreleaseiiiiiN(RRttstdbMatchthdrRtinstalledtsR(RRRRR((R
tkeyInstalleds

cCstdjotSn|pd|}ntii|pti|nt	|}|tid<ti
}ttii|dd}|id|i|i||i|i|}tii||titS(Ns	%s/gpgdirt	GNUPGHOMEsgpg.conftwbR}(tgpgmeRR(tgpgdirtcachedirRmRotexiststmakedirsRRtkey_fotenvirontContexttctxRctjointfpRRftimport_tget_keyRtkteditutilt
edit_trusttVALIDITY_ULTIMATER'(RRRRRRRR((R
timport_key_to_pubrings"





cCstdjptii|ogSn|tid<ti}g}xF|i
D]8}x/|iD]$}|io|i|iqeqeWqUW|S(NR(RRRmRoRRRRRtkeyidstkeylistRtsubkeystsubkeytcan_signR;R(RRRRR((R
treturn_keyids_from_pubrings!



c
CstdjotSn|o$tii|o|tid<nt|d}t|d}d}ti}y|i|||}Wntij
o
}	tSnEX|d}|ptSn|itititifjotSntS(sAtakes signature , file that was signed and an optional gpghomedirRR`iN(RRR(tgpghomeRmRoRRRctsig_filetsigtsigned_filetsigned_textt	plaintextRRtverifytsigst
GpgmeErrorRitthissigtvalidityt
VALIDITY_FULLtVALIDITY_MARGINALRR'(
RRRRRRRRRRi((R
tvalid_detached_sigs&
	
"s/var/tmpcCsti}
yti|
}|d}Wntj
od	SnXd}|od|}d||f}	t
ti|	}xb|D]V}ti|}t|do0t|ddjo|d|
jo|SqqWntid|d|}|S(
sqreturn a path to a valid and safe cachedir - only used when not running
       as root or when --tempcache is setisyum-syum-%s-s%s/%s*iitprefixtdirN(RmtgeteuidtuidtpwdtgetpwuidtusertuptusernameR{RRtreusettmpdirtdirpathtsortedtglobt	cachedirstthisdirtlstattstatstS_ISDIRtS_IMODEttempfiletmkdtempR(RRRRRRRRRRR((R
tgetCacheDirs&	
9cCs>|i|ijodSn |i|ijodSndSdS(s+sorts a list of yum package objects by nameiiiN(tpkg1Rtpkg2(RR((R
t
sortPkgObj#scCsr|ig}|d}xR|D]J}|i|o|g}|}q |i|o|i|q q W|S(s, Return the newest in the list of packages. iN(tpkgstpopRRtnewesttpkgtverGTtverEQR;(RRRRR((R
tnewestInList,s
	
cCs|\}}}d}|dddgjo|d|7}n|dj	o|d|7}n|dj	o|d|7}n|S(s
    Convert a tuple representing a package version to a string.

    @param evrTuple: A 3-tuple of epoch, version, and release.

    Return the string representation of evrTuple.
    R}it0s%s:s%ss-%sN(tevrTupleRitvR`RR(RRiRR`R((R
tversion_tuple_to_string8s

cCsr|\}}}hdd<dd<dd<dd<d	d
<}|djo|Snd|||t|fS(
s7returns a text string of the prco from the tuple formattGTt>tGEs>=tEQR~tLTt<tLEs<=s%s %s %sN(t	prcoTupleRtflagtevrtflagsRR(RRRR	R((R
tprco_tuple_to_stringKs3
cCs9tid|oti|}nti|}|S(smTakes a search string from the cli for Search or Provides
       and cleans it up so it doesn't make us vomits.*[\*,\[,\],\{,\},\?,\+].*N(RRtargtfnmatcht	translatetrestringtescape(RR((R
trefineSearchPatternUs
cCsti|d}t|d}xOtoGy|id}Wnt
j
oPnX|pPn|i|q$W|i|idS(s1 Extract the bzipped contents of source to dest. R`twiN(
tbz2tBZ2Filetsourcets_fnRctdesttdestinationR'RPRMRgRRf(RRRRMR((R
t
bunzipFile`s
cCsstid}ttid|}xC|D];}|id|}x |D]}|d|dfSqOWq0WdS(sgThis takes the output of uname and figures out the (version, release)
    tuple for the running kernel.is/boot/vmlinuz*%s*t	basenamesRRN(NN(RmtunametverRRtfnstfnRRtmithR(RRRRRR((R
t"get_running_kernel_version_releaseqss/var/lib/yumc	Csg}d|df}d|df}ti|}ti|}x?|D]7}ti	i
|}|idd}|i|qKW|i|S(sreturns a list of the timestamps from the filenames of the unfinished 
       transactions remaining in the yumlibpath specified.
    s%s/%sstransaction-all*stransaction-done*stransaction-all.R}N(t
timestampst
yumlibpathttsallgttsdonegRttsallsttsdonesRRmRotbasenamettranstreplaceRR;R6(	R"RR%R&R$R!R(R#R((R
tfind_unfinished_transactionss
cCs@g}d|d|f}d|d|f}g}tii|p|Sntii|o)t	|d}
|
i}|
int	|d}|i}|ix/|D]'}||joqn|i|qWxY|D]Q}|idd}|djoqn|i\}	}|i|	|fqW|S(sthis function takes the timestamp of the transaction to look at and 
       the path to the yum lib dir (defaults to /var/lib/yum)
       returns a list of tuples(action, pkgspec) for the unfinished transaction
       elements. Returns an empty list if none.

    s%s/%s.%sstransaction-allstransaction-doneR`s
R}N(tto_complete_itemsR"Rt	tsallpatht
tsdonepathttsdone_itemsRmRoRRct	tsdone_fot	readlinesRfttsall_fottsall_itemsRztremoveR)RtactiontpkgspecR;(RR"R5R.R1R+R-R,RzR4R/R2((R
tfind_ts_remainings6


cCsg}t|}t|}d}xD||jo6||}|i|||!||7}||8}q'W|i|||S(sE Given a seq, split into a list of lists of length max_entries each. iN(	RRR/tseqtnumR4tbegtmax_entriestendR;(R7R:R;R9RRR8((R
t
seq_max_splits


cCs|djodSnt|to|Snt}yt|d}t}Wntj
oddddg}x|D]v}yt||}Wntj
oqvX|i||jo1|djod||fGHn|idSqvqvWnXd}t
dd	d
dgt
dd
}xX|D]P}t||joq(|o!t|djo|d}q(||}q(W|S(shands back a unicoded stringR}tasciisutf-8s
iso-8859-1siso-8859-15s
iso-8859-2s
%s encoding on %s
iiiiii it?N(RzRRRR(tduR:R'tUnicodeErrort	encodingstenctencodetnewitemtrangetbad_small_bytestchartord(RzR?RFRGRBRARDR:((R
t_ugly_utf8_string_hacks>


&cCsudk}t|}t|}|i}|o(|iii	|dhdd<}n|iii	|}|S(Ntentitiest"s&quot;(
txml.sax.saxutilstxmlRIRztto_utf8trstriptattribtsaxtsaxutilsR(RzRPRM((R
tto_xmls	(cCsGyti|Wn/tj
o#}|itijoqCnXdS(s| 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(RmtunlinkR&RhRiterrnotENOENT(R&Ri((R
tunlink_fscCsy5titid|otitidnWnEtij
o6}tidIJdt	i
d<titidnX|o:dk}|i
titit_dti_ndS(NR}tCs%Failed to set locale, defaulting to CtLC_ALLR)(tlocalet	setlocaleRYt
override_timetLC_TIMEtErrorRitsyststderrRmRtoverride_codecstcodecst	getwritertgetpreferredencodingtstdoutterrors(RaR\RiRb((R
tsetup_locales

	!cCs<titi}|djo
d}ndi|}|S(NRXt.(NN(RZt	getlocaletLC_MESSAGEStmylangRR(Rk((R
tget_my_lang_code%s


(MRZRRmtos.patht	cStringIORRRRRURRRRRRtstatRtgpgme.editutiltImportErrorRRRFR?RRtErrorsRIti18nRNt
to_unicodetto_strRRRRRR R!R)R*R,R-R.R<R=R[RWRsRxRR(RRRRRRR'RRRRR
RRR R*R6R<RIRSRWRZR_RgRl(<RRRRtR R[RRRNR.R<RRgRZRRRRuRRURIRR
RlRR,RsRR)R6R?RRRR_RRRSR*R=RR<RFRRRRRRWRRRxRRIRWRRRmR R((R
R>s			
											
	
			

							BF		0		!						
			*		/	
		

Anon7 - 2021