a
    ¢ÀófX	  ã                   @   sz   d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZmZ ddg dfdd„Zdd	„ Zd
d„ ZdS )é    N)Ú
check_callÚcheck_output)ÚTarFile)ÚMETADATA_FNÚZONEFILENAMEÚgzc              	      sP  t  ¡ ‰ tj ˆ d¡}tj t¡}�zt | ¡�B}|D ]}| 	|ˆ ¡ q6‡ fdd„|D ƒ}	t
||	ƒ W d  ƒ n1 sx0    Y  ttj |t¡dƒ�"}
tj||
ddd� W d  ƒ n1 s¾0    Y  tj |t¡}t |d	| ¡�:}t |¡D ]}tj ||¡}| ||¡ qòW d  ƒ n1 �s(0    Y  W t ˆ ¡ nt ˆ ¡ 0 dS )
z‹Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*

    filename is the timezone tarball from ``ftp.iana.org/tz``.

    Zzoneinfoc                    s   g | ]}t j ˆ |¡‘qS © )ÚosÚpathÚjoin)Ú.0Ún©Ztmpdirr   úV/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/dateutil/zoneinfo/rebuild.pyÚ
<listcomp>   ó    zrebuild.<locals>.<listcomp>NÚwé   T)ÚindentÚ	sort_keyszw:%s)ÚtempfileÚmkdtempr	   r
   r   ÚdirnameÚ__file__r   ÚopenÚextractÚ_run_zicr   ÚjsonÚdumpr   ÚlistdirÚaddÚshutilÚrmtree)ÚfilenameÚtagÚformatZ
zonegroupsÚmetadataÚzonedirZ	moduledirÚtfÚnameÚ	filepathsÚfÚtargetÚentryZ	entrypathr   r   r   Úrebuild   s"    (00r.   c              
   C   st   zt ddgƒ}W n. ty> } zt|ƒ ‚ W Y d}~n
d}~0 0 d|v rRddg}ng }tdg| d| g | ƒ dS )a½  Calls the ``zic`` compiler in a compatible way to get a "fat" binary.

    Recent versions of ``zic`` default to ``-b slim``, while older versions
    don't even have the ``-b`` option (but default to "fat" binaries). The
    current version of dateutil does not support Version 2+ TZif files, which
    causes problems when used in conjunction with "slim" binaries, so this
    function is used to ensure that we always get a "fat" binary.
    Zzicz--helpNs   -b z-bÚfatz-d)r   ÚOSErrorÚ_print_on_nosuchfiler   )r'   r*   Ú	help_textÚeZ
bloat_argsr   r   r   r   )   s    

r   c                 C   s   | j dkrt d¡ dS )zdPrint helpful troubleshooting message

    e is an exception raised by subprocess.check_call()

    é   zzCould not find zic. Perhaps you need to install libc-bin or some other package that provides it, or it's not in your PATH?N)ÚerrnoÚloggingÚerror)r3   r   r   r   r1   A   s    
ÿr1   )r6   r	   r   r!   r   Ú
subprocessr   r   Útarfiler   Zdateutil.zoneinfor   r   r.   r   r1   r   r   r   r   Ú<module>   s   