£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
3
ft`t                 @   s   d dl mZ d dl mZ d dlmZ d dlmZmZ d dlm	Z	 d dlZ
d dlZ
d dlZ
d dlZ
d dlZ
d dlZd dlZd dlZd dlZejdZdd	d
gdgd	gd
gddd	gdZdd Zdd Zdd Zdd ZG dd dejZdS )    )absolute_import)unicode_literals)commands)_P_)miscNdnfmetadatadbcachezexpire-cachepackages)r	   r   r
   zexpire-cacheallc             c   sV   xPt j| D ]B\}}}t jj|| }x(|D ] }t jj||}t jj|V  q*W qW dS )z:Traverse dirpath recursively and yield relative filenames.N)oswalkpathrelpathjoinnormpath)dirpathrootdirsfilesbasefr    r   /usr/lib/python3.6/clean.py_tree1   s
    
r   c                s    fdd| D S )z5Yield those filenames that match any of the patterns.c             3   s(   | ] } D ]}t j||r
|V  q
qd S )N)rematch).0r   p)patternsr   r   	<genexpr><   s    z_filter.<locals>.<genexpr>r   )r   r    r   )r    r   _filter:   s    r"   c             C   sL   d}xB|D ]:}t jj| |}tjtjjtd| t	j
| |d7 }q
W |S )z(Remove the given filenames from dirpath.r   zRemoving file %s   )r   r   r   loggerlogr   loggingZDDEBUGr   r   Zunlink_f)r   r   countr   r   r   r   r   _clean?   s    

r(   c                s0   t jjd   fdd| D }tdd |D S )z:Return the repo IDs that have some cached metadata around.r	   c             3   s   | ]}t j |V  qd S )N)r   r   )r   r   )metapatr   r   r!   M   s    z _cached_repos.<locals>.<genexpr>c             s   s   | ]}|r|j d V  qdS )ZrepoidN)group)r   mr   r   r   r!   N   s    )r   repoCACHE_FILESset)r   Zmatchesr   )r)   r   _cached_reposJ   s    r/   c               @   s0   e Zd ZdZd	ZedZedd Zdd Z	dS )
CleanCommandzSA class containing methods needed by the cli to execute the
    clean command.
    cleanzremove cached datac             C   s   | j ddtj tdd d S )Ntype+zMetadata type to clean)nargschoiceshelp)add_argument_CACHE_TYPESkeysr   )parserr   r   r   set_argparserY   s    zCleanCommand.set_argparserc             C   sf  | j jj}tjj|d}tjj|d}tjj| j jjd}x$y|oJ|oJ| t	dd | j
jD }tt|}tjtddj|  d|krt|}| j jjj| |jd tjtd dd	 |D }t|t||}	tjtd
d|	|	  d S Q R X W q> tjjk
r\ }
 z:| j jjsHtd|
j }tj| tj d n|
W Y d d }
~
X q>X q>W d S )NTc             s   s    | ]}t | D ]
}|V  qqd S )N)r8   )r   ctr   r   r   r!   g   s    z#CleanCommand.run.<locals>.<genexpr>zCleaning data:  zexpire-cachezCache was expiredc             S   s   g | ]}t jj| qS r   )r   r,   r-   )r   r=   r   r   r   
<listcomp>q   s    z$CleanCommand.run.<locals>.<listcomp>z%d file removedz%d files removedz*Waiting for process with pid %d to finish.   )!r   Zconfcachedirr   lockZbuild_metadata_lockZbuild_download_lockZbuild_rpmdb_lockZ
persistdirr.   Zoptsr2   listr   r$   debugr   r   r/   Z_repo_persistorZexpired_to_addupdateremoveinfor(   r"   r   
exceptionsZ	LockErrorZexit_on_lockpidtimeZsleep)selfrA   Zmd_lockZdownload_lockZ
rpmdb_locktypesr   Zexpiredr    r'   emsgr   r   r   run_   s2    


zCleanCommand.runN)r1   )
__name__
__module____qualname____doc__aliasesr   Zsummarystaticmethodr;   rO   r   r   r   r   r0   Q   s
   r0   )Z
__future__r   r   Zdnf.clir   Zdnf.i18nr   r   Zdnf.yumr   r   Zdnf.exceptionsZdnf.lockZdnf.loggingZdnf.repor&   r   r   rJ   Z	getLoggerr$   r8   r   r"   r(   r/   ZCommandr0   r   r   r   r   <module>   s0   
	