ok

Mini Shell

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

3

�ft`o�@s�ddlmZddlmZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZejd�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZdS)�)�absolute_import)�unicode_literals)�_N�dnfc@s,eZdZdd�Zgfdd�Zedd��ZdS)�JSONDBcCs0tjj|�s,tjjtjj|��|j|g�dS)N)�os�path�isfiler�utilZ
ensure_dir�dirname�_write_json_db)�self�	json_path�r�/usr/lib/python3.6/persistor.py�_check_json_db+szJSONDB._check_json_dbcCs�t|d��}|j�}WdQRX|dkrDtjtd�|�|j||�n<ytj|�}Wn,tk
r~}ztj|�WYdd}~XnX|S)N�r�z%s is empty file)	�open�read�logger�warningrr�json�loads�
ValueError)r
r�default�f�content�errr�_get_json_db1szJSONDB._get_json_dbc
Cs&t|d��}tj||�WdQRXdS)N�w)rr�dump)rrrrrrr?szJSONDB._write_json_dbN)�__name__�
__module__�__qualname__rr�staticmethodrrrrrr)src@s<eZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dS)
�
RepoPersistorzePersistent data kept for repositories.

    Is arch/releasever specific and stores to cachedir.

    cCs*||_tjj|jd�|_t�|_d|_dS)Nzexpired_repos.jsonF)�cachedirrr�join�db_path�set�expired_to_add�reset_last_makecache)r
r'rrr�__init__LszRepoPersistor.__init__cCstjj|jd�S)NZlast_makecache)rrr(r')r
rrr�_last_makecache_pathRsz"RepoPersistor._last_makecache_pathcCsRy|j|j�t|j|j��Stk
rL}ztjtd�|�dSd}~XnXdS)Nz&Failed to load expired repos cache: %s)rr)r*r�OSErrorrrr)r
rrrr�get_expired_reposVszRepoPersistor.get_expired_reposcCs�y$|j|j�|j|jt|j��Wn0tk
rT}ztjtd�|�dSd}~XnX|j	r�yt
jj|j
�dStk
r�tjtd��dSXdS)Nz'Failed to store expired repos cache: %sFTz#Failed storing last makecache time.)rr)r�listr+r/rrrr,rr
Ztouchr.�IOError)r
rrrr�save^szRepoPersistor.savecCs:yttjj|j��Stk
r4tjtd��dSXdS)Nz'Failed determining last makecache time.)	�intrr
Zfile_ager.r/rrr)r
rrr�since_last_makecachems
z"RepoPersistor.since_last_makecacheN)
r"r#r$�__doc__r-�propertyr.r0r3r5rrrrr&Esr&c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TempfilePersistorcCs"tjj|d�|_t�|_d|_dS)Nztempfiles.jsonF)rrr(r)r*�tempfiles_to_add�_empty)r
r'rrrr-wszTempfilePersistor.__init__cCs|j|j�|j|j�S)N)rr)r)r
rrr�get_saved_tempfiles|sz%TempfilePersistor.get_saved_tempfilescCsp|jr|jrdS|j|j�|jr8|j|jg�dS|jrlt|j|j��}|j|j�|j|jt|��dS)N)	r:r9rr)rr*r�updater1)r
�datarrrr3�szTempfilePersistor.savecCs
d|_dS)NT)r:)r
rrr�empty�szTempfilePersistor.emptyN)r"r#r$r-r;r3r>rrrrr8usr8)Z
__future__rrZdnf.i18nrZdistutils.versionZ	distutilsZdnf.utilr�errnoZfnmatchrZloggingr�reZ	getLoggerr�objectrr&r8rrrr�<module>s
0

Zerion Mini Shell 1.0