ok

Mini Shell

Direktori : /lib/python3.6/site-packages/dnf/yum/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/yum/__pycache__/misc.cpython-36.pyc

3

�ft`W.�@sZdZddlmZmZddlmZddlmZmZmZddl	Tddl
ZddlZ
ddlZ
ddlZ
ddlZ
ddlZddlZddlZddlZddlZddlZddlZddlZddlZdgZdadd	�Zdad
d�Zdd
�ZGdd�de �Z!dd�Z"dd�Z#d,dd�Z$dd�Z%dd�Z&dd�Z'd-dd�Z(d d!�Z)da*d"d#�Z+d.d$d%�Z,d&d'�Z-d(d)�Z.d/d*d+�Z/dS)0z%
Assorted utility functions for yum.
�)�print_function�absolute_import)�unicode_literals)�base64_decodebytes�
basestring�unicode)�*NZsha256cCstdkrtjd�jat|�S)z( Tests if a string is a shell wildcard. Nz[*?]|\[.+\])�_re_compiled_glob_match�re�compile�search)�s�r�/usr/lib/python3.6/misc.py�re_glob.srcCsFtdkr(tjd�j}tjd�j}||faxtD]}||�r.dSq.WdS)zC Tests if a string needs a full nevra match, instead of just name. Nz.*([-.*?]|\[.+\]).z[0-9]+:TF)�_re_compiled_full_matchr
r�match)r
ZoneZtwoZrecrrr�re_full_search_needed6s
rcCstdS)Nr)�_default_checksumsrrrr�get_default_chksum_typeDsrc@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�
GenericHolderz�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 itNcCs
||_dS)N)�_GenericHolder__iter)�self�iterrrr�__init__MszGenericHolder.__init__cCs|jdk	rt||j�SdS)N)rr)rrrr�__iter__Ps
zGenericHolder.__iter__cCs t||�rt||�St|��dS)N)�hasattr�getattr�KeyError)r�itemrrr�__getitem__Ts

zGenericHolder.__getitem__cCsdd�t|�j�D�S)z!Return a dictionary of all lists.cSs"i|]\}}t|�tkr||�qSr)�type�list)�.0�keyZlist_rrr�
<dictcomp>\sz+GenericHolder.all_lists.<locals>.<dictcomp>)�vars�items)rrrr�	all_listsZszGenericHolder.all_listscCs4x.|j�j�D]\}}t|�j|g�j|�qW|S)z7 Concatenate the list attributes from 'other' to ours. )r(r'r&�
setdefault�extend)r�otherr$�valrrr�merge_lists_szGenericHolder.merge_lists)N)	�__name__�
__module__�__qualname__�__doc__rrr r(r-rrrrrGs
rcCs�tjdd|�}tj�}d}d}xn|jd�D]`}|jd�r>d}q*|rT|j�dkrTd}q*|rf|jd�rfPq*|rx|jd�rxPq*|r*|j|d�q*Wt|j	��S)	z,Convert ASCII-armored GPG key to binary
    s
?�
rs$-----BEGIN PGP PUBLIC KEY BLOCK-----��s"-----END PGP PUBLIC KEY BLOCK-----�=)
r
�sub�io�BytesIO�split�
startswith�strip�writer�getvalue)�rawkey�blockZinblockZpastheaders�linerrr�
procgpgkeyes 
rAcCsPxJ|jdd�D]:}|d|krt|dd�}||kr8dS||krDdSdSqWd	S)
ab
    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.
    �namez
gpg-pubkey�version�release�rr3����)ZdbMatch�int)Zts�keyidZ	timestampZhdrZinstalledtsrrr�keyInstalled�srJTcCstjj|�stj|�tjj|���tjj���}ttjj	|d�d��}|j
d�WdQRX|j|�|�r|d}tjj|��stj|dd�xFtj|d�D]4}tjj
|�}|d|}	tj||	�tj|	d�q�Wd	}
ttjj	|d�d
d��}|j
|
�WdQRXdSQRXWdQRXdS)Nzgpg.conf�wbr4z-roi�)�modez/*�/z�lock-never
    no-auto-check-trustdb
    trust-model direct
    no-expensive-trust-checks
    no-permission-warning
    preserve-permissions
    �wT)�os�path�exists�makedirs�dnfZcryptoZpubring_dirZContext�open�joinr<Z	op_import�glob�basename�shutil�copy�chmod)r>rIZgpgdirZmake_ro_copyZctx�fpZrodir�frWZro_fZoptsrrr�import_key_to_pubring�s&

r]c	Cs�tj�}y.tj|�}tjj|d�}dtjj|f}Wn$t	k
rZdtjj|f}YnXdtjj
|f}ttj|��}xB|D]:}tj
|�}t|d�r�t|d�dkr�|d|kr�|Sq�Wtj|tjj
d�}|S)zqreturn a path to a valid and safe cachedir - only used when not running
       as root or when --tempcache is setrz%s-%s-z%s/%s*i��)�prefix�dir)rO�geteuid�pwd�getpwuidrSZi18nZucd�constZPREFIXrZTMPDIR�sortedrV�lstat�S_ISDIR�S_IMODE�tempfileZmkdtemp)	ZuidZusertupZusernamer_�dirpathZ	cachedirsZthisdirZstatsZcachedirrrr�getCacheDir�s


(rkcCsfg}t|�}t|�}d}x6||krN||}|j|||��||7}||8}qW|j||d��|S)zE Given a seq, split into a list of lists of length max_entries each. rN)�lenr"�append)�seqZmax_entries�retZnumZbeg�endrrr�
seq_max_split�s
rqcCsDytj|�Wn0tk
r>}z|jtjkr.�WYdd}~XnXdS)z| 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)rO�unlink�OSError�errno�ENOENT)�filename�errr�unlink_f�s
rxFcCs^y
tj|�Stk
rX}z2|jtjtjfkr2dS|rF|jtjkrFdS�WYdd}~XnXdS)zF Call os.stat(), but don't die if the file isn't there. Returns None. N)rO�statrsrtru�ENOTDIRZEACCES)rvZ
ignore_EACCESrwrrr�stat_f�s
r{cCsFy$td��}|j�}t|�SQRXWnttfk
r@tj�SXdS)z� 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. z/proc/self/loginuidN)rT�readrH�IOError�
ValueErrorrO�getuid)�fo�datarrr�_getloginuid�s
r�cCstdkrt�atS)z� 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)�_cached_getloginuidr�rrrr�getloginuidsr�c	Cs�|r
|}nJd}|jd�}|dkr@||d�}|dkr@|d|�}|dkrTtjjd
��|r�t|�}t|�}|r�|r�|j|jkr�|Sytjj||d�Wn2t	k
r�}ztjjt
|���WYdd}~XnX|r�|r�tj||j|jf�|S)
z�take a filename and decompress it into the same relative location.
       When the compression type is not recognized (or file is not compressed),
       the content of the file is copied to the destinationN�.r�.zck�.xz�.bz2�.gz�.lzma�.zstz(Could not determine destination filenamei�)r�r�r�r�r�r�)
�rfindrS�
exceptionsZ	MiscErrorr{�st_mtime�libdnfZutils�
decompress�RuntimeError�strrO�utime)	rv�dest�check_timestamps�outZdot_posZextZfir�rwrrrr�s,
"r�cCs:tjj|�}|d7}tjj|�s.tj|dd�|d|S)Nz/geni�)rLrM)rOrP�dirnamerQrR)rv�generated_namer�rrr�calculate_repo_gen_dest8s
r�cCst||�}t||dd�S)z� 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. T)r�r�)r�r�)rvr�r�rrr�repo_gen_decompress@s
r�cCs�g}x�tj|�D]�}t|��n}xf|D]^}tjd|�r6q$|j�}|j�}|sLq$|rx|jdd�}|jdd�}|j|j��q$|j	|�q$WWdQRXqW|S)a( 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.
    z\s*(#|$)�
� �,N)
rVrTr
r�rstrip�lstrip�replacer*r9rm)ZthisglobZline_as_list�resultsZfnamer\r@rrr�read_in_items_from_dot_dirHs"

r�)NT)F)NF)T)0r1Z
__future__rrrZ
dnf.pycomprrrryZlibdnf.utilsr�Z	dnf.constrSZ
dnf.cryptoZdnf.exceptionsZdnf.i18nrtrVr7rOZos.pathrbr
rXrirr	rrrr�objectrrArJr]rkrqrxr{r�r�r�r�r�r�r�rrrr�<module>sN
#	


#

Zerion Mini Shell 1.0