ó ¾[/\c@@sVddlmZddlmZddlmZddlmZmZddlm Z ddlZ ddl Z ddl Z ddl Z ddlZ ddlZddlZddlZddlZejdƒZidd d gd6d gd 6d gd 6d gd 6dd d gd 6Zd „Zd„Zd„Zd„Zdejfd„ƒYZdS(i(tabsolute_import(tunicode_literals(tcommands(t_tP_(tmiscNudnfumetadataudbcacheu expire-cacheupackagesuallcc@ssxltj|ƒD][\}}}tjj||ƒ}x4|D],}tjj||ƒ}tjj|ƒVq;WqWdS(u:Traverse dirpath recursively and yield relative filenames.N(tostwalktpathtrelpathtjointnormpath(tdirpathtroottdirstfilestbasetfR((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyt_tree1s  c@s‡fd†|DƒS(u5Yield those filenames that match any of the patterns.c3@s4|]*}ˆD]}tj||ƒr |Vq qdS(N(tretmatch(t.0Rtp(tpatterns(s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pys <s((RR((Rs:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyt_filter:scC@sfd}xY|D]Q}tjj||ƒ}tjtjjtdƒ|ƒt j |ƒ|d7}q W|S(u(Remove the given filenames from dirpath.iuRemoving file %si( RRR tloggertlogtdnftloggingtDDEBUGRRtunlink_f(R RtcountRR((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyt_clean?s  c@s:tjjd‰‡fd†|Dƒ}td„|DƒƒS(u:Return the repo IDs that have some cached metadata around.umetadatac3@s!|]}tjˆ|ƒVqdS(N(RR(RR(tmetapat(s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pys Mscs@s$|]}|r|jdƒVqdS(urepoidN(tgroup(Rtm((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pys Ns(Rtrepot CACHE_FILEStset(Rtmatches((R!s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyt _cached_reposJst CleanCommandcB@s8eZdZdZedƒZed„ƒZd„ZRS(uSA class containing methods needed by the cli to execute the clean command. ucleanuremove cached datac C@s/|jddddtjƒdtdƒƒdS(Nutypetnargsu+tchoicesthelpuMetadata type to clean(t add_argumentt _CACHE_TYPEStkeysR(tparser((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyt set_argparserYs c C@sá|jjj}tjj|tƒ}tjj|tƒ}tjj|jjj tƒ}xƒtrÜy|or|or|t d„|j j Dƒƒ}t t|ƒƒ}tjtddj|ƒƒƒd|krt|ƒ}|jjjj|ƒ|jdƒtjtdƒƒng|D]}tjj|^q} t|t|| ƒƒ} tjtdd| ƒ| ƒdSWdQXWqZtjjk rØ} |jjj sÏtd| j!ƒ} tj| ƒt"j#d ƒqÙ| ‚qZXqZWdS( Ncs@s&|]}t|D] }|VqqdS(N(R.(Rtctt((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pys gsuCleaning data: u u expire-cacheuCache was expiredu%d file removedu%d files removedu*Waiting for process with pid %d to finish.i($RtconftcachedirRtlocktbuild_metadata_locktTruetbuild_download_locktbuild_rpmdb_lockt persistdirR&toptsttypetlistRRtdebugRR R(t_repo_persistortexpired_to_addtupdatetremovetinfoR$R%R RRt exceptionst LockErrort exit_on_locktpidttimetsleep( tselfR5tmd_lockt download_lockt rpmdb_lockttypesRtexpiredR3RRtetmsg((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pytrun_s2     # (uclean( t__name__t __module__t__doc__taliasesRtsummaryt staticmethodR1RS(((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyR)Qs  (t __future__RRtdnf.cliRtdnf.i18nRRtdnf.yumRRtdnf.exceptionstdnf.lockt dnf.loggingtdnf.repoRRRRIt getLoggerRR.RRR R(tCommandR)(((s:/usr/lib/python2.7/site-packages/dnf/cli/commands/clean.pyts2