
    dfP                     ~    d dl Z d dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dl
mZmZmZ d Zd Z G d de          ZdS )	    N)Path)BaseCommandCommandError)find_commandis_ignored_pathpopen_wrapperc                     |                      d          5 }|                    d          }d d d            n# 1 swxY w Y   |                    t          j        t          j        t          j        f          S )Nrb   )openread
startswithcodecsBOM_UTF8BOM_UTF16_LEBOM_UTF16_BE)fnfsamples      kD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/core/management/commands/compilemessages.pyhas_bomr      s    	 !              	&-v/BC  s   8<<c                     	 t          | d          5  t          j        | d            d d d            n# 1 swxY w Y   n# t          $ r Y dS w xY wdS )NaFT)r   osutimeOSError)paths    r   is_writabler      s    $__ 	! 	!HT4   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!   uu4s,   A  4A  8A  8A   
AAc                   2    e Zd ZdZg ZdZdgZd Zd Zd Z	dS )CommandzECompiles .po files to .mo files for use with builtin gettext support.msgfmtz--check-formatc           	          |                     dddg d           |                     dddg d           |                     d	d
ddd           |                     ddddg dd           d S )Nz--localez-lappendzYLocale(s) to process (e.g. de_AT). Default is to process all. Can be used multiple times.)actiondefaulthelpz	--excludez-xz@Locales to exclude. Default is none. Can be used multiple times.z--use-fuzzy-ffuzzy
store_truezUse fuzzy translations.)destr$   r&   z--ignorez-iignore_patternsPATTERNzWIgnore directories matching this glob-style pattern. Use multiple times to ignore more.)r$   r*   r%   metavarr&   )add_argument)selfparsers     r   add_argumentszCommand.add_arguments&   s    * 	 	
 	
 	
 	S 	 	
 	
 	
 	* 	 	
 	
 	
 	"1 	 		
 		
 		
 		
 		
    c           
      (   |d         }|d         }t          |d                   }|d         | _        |d         r| j        dgz   | _        t          | j                  t          d| j        z            t          j                            dd          dg}t          j	        
                    d	          r d
dlm} |                    |j                   t          j        dd          D ]\  }}|D ]}	t!          t          j                            t          j                            |	                    |          r|                    |	           c|	dk    r3|                    t          j                            |	                     t          t)          t          j        j        t-          t          j        j        |                              }|st          d          g }
|D ]ht-          t          j        j        t1          j        dz                      }|
                    t)          t          j        j        |                     i|p|
}t          |                              |          }d| _        |D ]p|rfd|D             }ng}g }|D ]>}t          j        |          D ]'\  }}|                    fd|D                        (?|r|                     |           q| j        rt          d          d S )Nlocaleexcluder+   	verbosityr(   r'   zLCan't find %s. Make sure you have GNU gettext tools 0.15 or newer installed.confDJANGO_SETTINGS_MODULEr   )settings.T)topdownzzThis script should be run from the Django Git checkout or your project or app tree, or with the settings module specified.z%s/*Fc                 R    g | ]#}t           j                            |d           $S )LC_MESSAGES)r   r   join).0r4   basedirs     r   
<listcomp>z"Command.handle.<locals>.<listcomp>}   s8       EKBGLL&-@@  r2   c              3   J   K   | ]}|                     d           |fV  dS )z.poN)endswith)r?   r   dirpaths     r   	<genexpr>z!Command.handle.<locals>.<genexpr>   sL       % %)*1::e;L;L% !% % % % % %r2   z-compilemessages generated one or more errors.)setr6   program_optionsr   programr   r   r   r>   environgetdjango.confr9   extendLOCALE_PATHSwalkr   normpathremover#   mapabspathfilterisdirglobbasename
difference
has_errorscompile_messages)r/   optionsr4   r5   r+   basedirsr9   dirnames	filenamesdirnameall_localeslocale_dirslocalesdirs	locationsldirr@   rD   s                   @@r   handlezCommand.handleH   s   ")$g&7899 -7 	A#'#74&#@D %%-137<@  
 GLL22H=:>>233 	3,,,,,,OOH1222 -/GC,F,F,F 	D 	D(GXy# D D"G$$RW\\'7%C%CDDo  D OOG,,,,((OOBGLL'$B$BCCCD s27?F27=(,K,KLLMM 	1    	C 	CG 	&7:J0K0KLLKs27#3[AABBBB 'Kg,,))'22 	1 	1G !   OV    yI  46GDMM  0GXy$$ % % % %.7% % %      1%%i000? 	PNOOO	P 	Pr2   c                    t           j                                        5 }g }t          |          D ]\  }\  }}t	          |          |z  }|                    d          }	 |                                j        |                                j        k    r)| j        dk    r| j	        
                    d|z             n# t          $ r Y nw xY w| j        dk    r | j	        
                    d|d|           t          |          r%| j        
                    d|z             d| _        |dk    rAt          |          s2| j        
                    d|z             d| _         d	d	d	           d	S | j        g| j        d
||}	|                    |                    t(          |	                     t           j                            |          D ]x}
|
                                \  }}}|r\| j        dk    rJ|r&| j        
                    d| j        d|           n"| j        
                    d| j        z             d| _        y	 d	d	d	           d	S # 1 swxY w Y   d	S )zI
        Locations is a list of tuples: [(directory, file), ...]
        z.mor   u1   File “%s” is already compiled and up to date.zprocessing file z in zmThe %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.TzeThe po files under %s are in a seemingly not writable location. mo files will not be updated/created.Nz-ozExecution of z	 failed: zExecution of %s failed)
concurrentfuturesThreadPoolExecutor	enumerater   with_suffixstatst_mtimer6   stdoutwriteFileNotFoundErrorr   stderrrX   r   rH   rG   r#   submitr   as_completedresult)r/   rc   executorrh   irD   r   po_pathmo_pathargsfutureoutputerrorsstatuss                 r   rY   zCommand.compile_messages   s+    2244 1	+G#,Y#7#7 #E #E<GQw--!+!--e44	||~~.',,..2III>A-- K-- S")!*   ! J )   D>A%%K%%%AAAww&OPPP7## K%%S!"  
 '+DO 66+g"6"66K%%JLST   '+DOE1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+H Tt';TTT7TGTx}dCCDDDD$,99'BB 
+ 
+)/& +~))! W K---@Dff U    !K--.F.UVVV&*DO
+O1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+ 1	+s?   AI!"AC >I! 
C
I!CBI!6CI!!I%(I%N)
__name__
__module____qualname__r&   requires_system_checksrH   rG   r1   re   rY    r2   r   r    r       sa        RDG'(O 
  
  
DDP DP DPL5+ 5+ 5+ 5+ 5+r2   r    )r   concurrent.futuresrg   rU   r   pathlibr   django.core.management.baser   r   django.core.management.utilsr   r   r   r   r   r    r   r2   r   <module>r      s          				       A A A A A A A A U U U U U U U U U U    e+ e+ e+ e+ e+k e+ e+ e+ e+ e+r2   