Edit File: persistor.cpython-36.pyc
3 �ft`o������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZ�d�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlZd�dl Z d�dlZejd�ZG�dd��de�ZG�dd ��d e�ZG�d d��de�ZdS�)�����)�absolute_import)�unicode_literals)�_N�dnfc���������������@���s,���e�Zd�Zdd��Zg�fdd�Zedd���ZdS�)�JSONDBc�������������C���s0���t�jj|�s,tjjt�jj|���|�j|g���d�S�)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_dbc�������������C���s����t�|d��}|j��}W�d�Q�R�X�|dkrDtjtd�|��|�j||��n<ytj|�}W�n,�tk r~�}�ztj|��W�Y�d�d�}~X�nX�|S�)N�r��z%s is empty file) �open�read�logger�warningr���r����json�loads� ValueError)r ���r����default�f�content�er���r���r����_get_json_db1���s����zJSONDB._get_json_dbc���������� ���C���s&���t�|�d��}tj||��W�d�Q�R�X�d�S�)N�w)r���r����dump)r���r���r���r���r���r���r���?���s����zJSONDB._write_json_dbN)�__name__� __module__�__qualname__r���r����staticmethodr���r���r���r���r���r���)���s���r���c���������������@���s<���e�Zd�ZdZdd��Zedd���Zdd��Zdd ��Zd d��Z dS�) � RepoPersistorzePersistent data kept for repositories. Is arch/releasever specific and stores to cachedir. c�������������C���s*���||�_�tjj|�j�d�|�_t��|�_d|�_d�S�)Nzexpired_repos.jsonF)�cachedirr���r����join�db_path�set�expired_to_add�reset_last_makecache)r ���r'���r���r���r����__init__L���s����zRepoPersistor.__init__c�������������C���s���t�jj|�jd�S�)NZlast_makecache)r���r���r(���r'���)r ���r���r���r����_last_makecache_pathR���s����z"RepoPersistor._last_makecache_pathc�������������C���sR���y|�j�|�j��t|�j|�j��S��tk rL�}�ztjtd�|��d�S�d�}~X�nX�d�S�)Nz&Failed to load expired repos cache: %s)r���r)���r*���r����OSErrorr���r���r���)r ���r���r���r���r����get_expired_reposV���s����zRepoPersistor.get_expired_reposc�������������C���s����y$|�j�|�j��|�j|�jt|�j���W�n0�tk rT�}�ztjtd�|��dS�d�}~X�nX�|�j r�yt jj|�j ��dS��tk r����tjtd���dS�X�d�S�)Nz'Failed to store expired repos cache: %sFTz#Failed storing last makecache time.)r���r)���r����listr+���r/���r���r���r���r,���r���r ���Ztouchr.����IOError)r ���r���r���r���r����save^���s����zRepoPersistor.savec�������������C���s:���yt�tjj|�j��S��tk r4���tjtd���d�S�X�d�S�)Nz'Failed determining last makecache time.) �intr���r ���Zfile_ager.���r/���r���r���r���)r ���r���r���r����since_last_makecachem���s ����z"RepoPersistor.since_last_makecacheN) r"���r#���r$����__doc__r-����propertyr.���r0���r3���r5���r���r���r���r���r&���E���s���r&���c���������������@���s,���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd S�) �TempfilePersistorc�������������C���s"���t�jj|d�|�_t��|�_d|�_d�S�)Nztempfiles.jsonF)r���r���r(���r)���r*����tempfiles_to_add�_empty)r ���r'���r���r���r���r-���w���s����zTempfilePersistor.__init__c�������������C���s���|�j�|�j��|�j|�j�S�)N)r���r)���r���)r ���r���r���r����get_saved_tempfiles|���s����z%TempfilePersistor.get_saved_tempfilesc�������������C���sp���|�j��r|�j�rd�S�|�j|�j��|�j�r8|�j|�jg���d�S�|�jrlt|�j|�j��}|j|�j��|�j|�jt|���d�S�)N) r:���r9���r���r)���r���r*���r����updater1���)r ����datar���r���r���r3�������s����zTempfilePersistor.savec�������������C���s ���d|�_�d�S�)NT)r:���)r ���r���r���r����empty����s����zTempfilePersistor.emptyN)r"���r#���r$���r-���r;���r3���r>���r���r���r���r���r8���u���s���r8���)Z __future__r���r���Zdnf.i18nr���Zdistutils.versionZ distutilsZdnf.utilr����errnoZfnmatchr���Zloggingr����reZ getLoggerr����objectr���r&���r8���r���r���r���r����<module>���s��� 0