U
    md                     @   sN   d Z ddlZddlZddlZddlZdd Zdd Zdd Zed	koHe  dS )
z
Generate the zip test data files.

Run to build the tests/zipdataNN/ziptestdata.zip files from
files in tests/dataNN.

Replaces the file with the working copy, but does commit anything
to the source repo.
    Nc                  C   s   d} t tt|  dS )a;  
    >>> from unittest import mock
    >>> monkeypatch = getfixture('monkeypatch')
    >>> monkeypatch.setattr(zipfile, 'ZipFile', mock.MagicMock())
    >>> print(); main()  # print workaround for bpo-32509
    <BLANKLINE>
    ...data01... -> ziptestdata/...
    ...
    ...data02... -> ziptestdata/...
    ...
    )Z01Z02N)tuplemapgenerate)suffixes r   ^/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/importlib_resources/tests/update-zips.pymain   s    r   c              	   C   s   t tjt }|d|  d }t|dL}t	|d|   D ]2\}}dt 
|  }t|d| ||| qFW 5 Q R X d S )NZzipdataz/ziptestdata.zipwdataZziptestdataz->)pathlibPath__file__parentrelative_toosgetcwdzipfileZipFilewalkPurePosixPathas_posixprintwrite)suffixrootZzfpathzfsrcreldstr   r   r   r   !   s    r   c              
   c   sf   t | D ]V\}}}tt |d W 5 Q R X |D ]&}t|| }|| }||fV  q8q
d S )N__pycache__)	r   r   
contextlibsuppress
ValueErrorremover   r   r   )datapathdirpathdirnames	filenamesfilenameresr   r   r   r   r   +   s    
r   __main__)	__doc__r    r   r   r   r   r   r   __name__r   r   r   r   <module>   s   


