
                         L    S r SSKrSSKrSSKrSSKrSSKrS r " S S\5      rg)z=Context managers for patching libraries for use in PAR files.    Nc                 \   [         R                  R                  [        R                  5      (       a  g[
        R                  " SS5      n[         R                  R                  U S5      n[        US5       nUR                  U5        SSS5        U[        l        g! , (       d  f       N= f)a  Patch things so that httplib2 works properly in a PAR.

Manually extract certificates to file to make OpenSSL happy and avoid error:
   ssl.SSLError: [Errno 185090050] _ssl.c:344: error:0B084002:x509 ...

Args:
  extract_dir: the directory into which we extract the necessary files.
Nhttplib2zcacerts.txtwb)
ospathisfiler   CA_CERTSpkgutilget_datajoinopenwrite)extract_dircacerts_contentscacerts_filenamefs       3lib/third_party/containerregistry/tools/patched_.py_monkey_patch_httplib2r      sx     WW^^H%%&&
%%j-@WW\\+}=d#qGG $&( $#s   7B
B+c                   &    \ rS rSrS rS rS rSrg)Httplib2,   c                 8    [         R                  " 5       U l        g N)tempfilemkdtemp_tmpdirselfs    r   __init__Httplib2.__init__.   s    ##%DL    c                 0    [        U R                  5        U $ r   )r   r   r   s    r   	__enter__Httplib2.__enter__2   s    4<<(Kr!   c                 D    [         R                  " U R                  5        g r   )shutilrmtreer   )r   unused_typeunused_valueunused_tracebacks       r   __exit__Httplib2.__exit__6   s    
MM$,,r!   )r   N)__name__
__module____qualname____firstlineno__r   r#   r+   __static_attributes__ r!   r   r   r   ,   s    & r!   r   )	__doc__r   r
   r&   r   r   r   objectr   r2   r!   r   <module>r5      s+    D 	    '& v  r!   