
                             d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlmZ  G d dej                        Z
 G d	 d
ej                        Z G d dej                        Zy)z9Custom argument parsers for Certificate Manager commands.    )absolute_import)division)unicode_literalsN)arg_parsersc                        e Zd ZdZ ej
                  dej                  ej                  z        Z fdZ	 fdZ
 xZS )PemCertificatesFilezReads file from provided path, extracts all PEM certificates from that file, and packs them into a message format appropriate for use in the Trust Store.zY-----BEGIN CERTIFICATE-----\s*[\r\n|\r|\n][\w\s+/=]+[\r\n|\r|\n]-----END CERTIFICATE-----c                 .    t         t        |   d       y )NF)binary)superr   __init__)self	__class__s    Alib/googlecloudsdk/command_lib/certificate_manager/arg_parsers.pyr   zPemCertificatesFile.__init__%   s    	
t-U-;    c                     t         t        |   |      }| j                  j	                  |      }|D cg c]  }d|i c}S c c}w )NpemCertificate)r   r   __call__PEM_REfindall)r   namefile_contentscertscertr   s        r   r   zPemCertificatesFile.__call__(   sG    -t=dCMKK.E167t$777s   A)__name__
__module____qualname____doc__recompileDOTALLASCIIr   r   r   __classcell__r   s   @r   r   r      s?     b2::# 	ii"((	&<8 8r   r   c                   ,     e Zd ZdZ fdZ fdZ xZS )*SemicolonSeparatedPemCertificatesFilesList/Reads PEM certificates from all provided files.c                 B    t        t        | 
  dt               dd| y)RInitialize the parser.

    Args:
      **kwargs: Passed verbatim to ArgList.
    ;element_typecustom_delim_charN )r   r%   r   r   r   kwargsr   s     r   r   z3SemicolonSeparatedPemCertificatesFilesList.__init__1   s-     

4dD (* r   c                 z    t         t        |   |      }t        t        j
                  j                  |            S N)r   r%   r   list	itertoolschainfrom_iterabler   	arg_valuevaluer   s      r   r   z3SemicolonSeparatedPemCertificatesFilesList.__call__=   s4    <dLE 	--e455r   r   r   r   r   r   r   r"   r#   s   @r   r%   r%   .       7
6 6r   r%   c                   ,     e Zd ZdZ fdZ fdZ xZS )&CommaSeparatedPemCertificatesFilesListr&   c                 B    t        t        | 
  dt               dd| y)r(   ,r*   Nr-   )r   r<   r   r   r.   s     r   r   z/CommaSeparatedPemCertificatesFilesList.__init__G   s-     

0$@ (* r   c                 z    t         t        |   |      }t        t        j
                  j                  |            S r1   )r   r<   r   r2   r3   r4   r5   r6   s      r   r   z/CommaSeparatedPemCertificatesFilesList.__call__S   s4    8$HE 	--e455r   r9   r#   s   @r   r<   r<   D   r:   r   r<   )r   
__future__r   r   r   r3   r   googlecloudsdk.callioper   FileContentsr   ArgListr%   r<   r-   r   r   <module>rD      sS    @ &  '  	 /8+22 8&61D1D 6,6[-@-@ 6r   