
    	                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ  G d	 d
ej                        Zy)zThe meta cache delete command.    )absolute_import)division)unicode_literals)base)
cache_util)log)
console_ioc                   &    e Zd ZdZed        Zd Zy)Deletez1Delete a persistent cache or tables in the cache.c                 V    t        j                  |        | j                  ddd       y )Ntables*zThe table names or name patterns to delete, where `?` matches any character and ```*``` matches any string of zero or more characters. If omitted then the entired cache is deleted.)nargshelp)r   AddCacheFlagadd_argument)parsers     lib/surface/meta/cache/delete.pyArgszDelete.Args   s0    F#
J  L    c                 n   d }|j                   s8|j                  d      s' ||j                         t        j                          y t        j
                  |j                        5 }t        j                  dj                  |j                               |j                   r|j                   D cg c]  }|j                  |      D ]  }|  }}}|s=t        j                  dj                  dj                  |j                                     t        j                  dj                  dj                  |            dd       |D ]#  }|j                  |      }|j	                          % 	 d d d        y  ||j                         |j	                          d d d        y c c}}w # 1 sw Y   y xY w)	Nc                 R    t        j                  dj                  |       dd       y)z2Prompt for cache deletion and return confirmation.z&The entire [{}] cache will be deleted.T)messagecancel_on_nodefaultN)r	   PromptContinueformat)names    r   _RequireConfirmationz(Delete.Run.<locals>._RequireConfirmation+   s$    :AA$Gr   cachezcache name {}zNo tables matched [{}].,z[{}] will be deleted.T)r   r   r   )r   IsSpecifiedr    r   r   GetCacher   infor   r   SelectNoTablesMatchedjoinr	   r   Table)selfargsr   r    patternr   namestables           r   Runz
Delete.Run)   sb    ;;t//84::&			TZZ	(E	hh%%ejj12	%)[[ 4['"\\'2T 2 [ 4**+D+K+Khht{{#,% & &!!+22388E?C	 D++d#%
,,.   
)	(" 5::&lln% 
)( #4 
)( s&   'A
F+1F%B!F+:"F+%F++F4N)__name__
__module____qualname____doc__staticmethodr   r.    r   r   r   r      s    9L L"r   r   N)r2   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.metar   googlecloudsdk.corer   googlecloudsdk.core.consoler	   Commandr   r4   r   r   <module>r;      s/     % &  ' ( 6 # 2/T\\ /r   