
    Mh`                       d Z ddlmZ ddlZddlZddlZddlZddlZ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 ddlmZ ddlmZmZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z*  ej+        d          Z, G d de-          Z. G d de.          Z/ G d de.          Z0 G d de.          Z1dAdZ2 G d d          Z3 G d de3          Z4d Z5 G d de3          Z6 G d  d!e3          Z7 G d" d#e3          Z8 G d$ d%          Z9d& Z:dAd'Z;dAd(Z<d)d*dBd-Z=	 	 dCdDd5Z>dEd9Z?dFdGd=Z@dHd?ZAeBd@k    r e:             dS dS )Iz
    babel.messages.frontend
    ~~~~~~~~~~~~~~~~~~~~~~~

    Frontends for the message extraction functionality.

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    )annotationsN)RawConfigParser)StringIO)BinaryIOIterableLiteral)Locale
localedata)__version__)UnknownLocaleError)DEFAULT_HEADERCatalog)DEFAULT_KEYWORDSDEFAULT_MAPPINGcheck_and_call_extract_fileextract_from_dir)write_mo)read_powrite_po)LOCALTZbabelc                      e Zd ZdS )	BaseErrorN__name__
__module____qualname__     W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/babel/messages/frontend.pyr   r   ,           Dr   r   c                      e Zd ZdS )OptionErrorNr   r   r   r    r#   r#   0   r!   r   r#   c                      e Zd ZdS )
SetupErrorNr   r   r   r    r%   r%   4   r!   r   r%   c                      e Zd ZdZdS )ConfigurationErrorz3
    Raised for errors in configuration files.
    N)r   r   r   __doc__r   r   r    r'   r'   8   s           r   r'   c                   g }t          | t          t          f          s| g} | D ]}|t          |t          t          f          r%|                    t	          ||                     F|                    d t          |                              |          D                        t          d |D                       sJ |S )a  
    Make a list out of an argument.

    Values from `distutils` argument parsing are always single strings;
    values from `optparse` parsing may be lists of strings that may need
    to be further split.

    No matter the input, this function returns a flat list of whitespace-trimmed
    strings, with `None` values filtered out.

    >>> listify_value("foo bar")
    ['foo', 'bar']
    >>> listify_value(["foo bar"])
    ['foo', 'bar']
    >>> listify_value([["foo"], "bar"])
    ['foo', 'bar']
    >>> listify_value([["foo"], ["bar", None, "foo"]])
    ['foo', 'bar', 'foo']
    >>> listify_value("foo, bar, quux", ",")
    ['foo', 'bar', 'quux']

    :param arg: A string or a list of strings
    :param split: The argument to pass to `str.split()`.
    :return:
    Nsplitc              3  >   K   | ]}|                                 V  d S Nstrip).0ss     r    	<genexpr>z listify_value.<locals>.<genexpr>c   s*      <<17799<<<<<<r   c              3  @   K   | ]}t          |t                    V  d S r-   )
isinstancestr)r0   vals     r    r2   z listify_value.<locals>.<genexpr>d   s,      33z#s##333333r   )r4   listtupleextendlistify_valuer5   r+   all)argr+   outr6   s       r    r:   r:   >   s    4 CcD%=)) e = =;cD%=)) 	JJ}S666777

<<c#hhnnU&;&;<<<<<<<33s33333333Jr   c                  @    e Zd ZdZdZdZi Zi ZeZddZ	d Z
d Zd ZdS )CommandMixinNr   c                    || _         |                                  d | _        d| _        d | _        d| _        d| _        d S )NFr   )distributioninitialize_options_dry_runverboseforcehelp	finalized)selfdists     r    __init__zCommandMixin.__init__   sC     !!!
	r   c                    d S r-   r   rH   s    r    rB   zCommandMixin.initialize_options   s    r   c                J    | j         s|                                  d| _         d S )N   )rG   finalize_optionsrL   s    r    ensure_finalizedzCommandMixin.ensure_finalized   s)    ~ 	$!!###r   c                2    t          d| j         d          )Nzabstract method -- subclass z must override)RuntimeError	__class__rL   s    r    rO   zCommandMixin.finalize_options   s$    I4>III
 
 	
r   r-   )r   r   r   as_argsmultiple_value_optionsboolean_optionsoption_aliasesoption_choiceslogrJ   rB   rP   rO   r   r   r    r?   r?   h   s        
 G   O N N C       

 
 
 
 
r   r?   c                  :    e Zd ZdZg dZddgZd Zd Zd Zd Z	d	S )
CompileCatalogz+compile message catalogs to binary MO files))domain=Dz>domains of PO files (space separated list, default 'messages'))z
directory=d.path to base directory containing the catalogszinput-file=izname of the input file)output-file=ozQname of the output file (default '<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')locale=lz locale of the catalog to compile)	use-fuzzyfzalso include fuzzy translations)
statisticsNz#print statistics about translationsrg   ri   c                h    d| _         d | _        d | _        d | _        d | _        d| _        d| _        d S NmessagesF)domain	directory
input_fileoutput_filelocale	use_fuzzyri   rL   s    r    rB   z!CompileCatalog.initialize_options   s8     r   c                    t          | j                  | _        | j        s| j        st	          d          | j        s| j        st	          d          d S d S )Nz<you must specify either the input file or the base directoryz=you must specify either the output file or the base directory)r:   rm   ro   rn   r#   rp   rL   s    r    rO   zCompileCatalog.finalize_options   st    #DK00 	^t~ 	^\]]] 	_ 	_]^^^	_ 	_ 	_ 	_r   c                    d}| j         D ]>}|                     |                                          D ]}|t          |          z  }?|r| j                            d|           |rdndS )Nr   z%d errors encountered.rN   )rm   _run_domainvalueslenrY   error)rH   n_errorsrm   errorss       r    runzCompileCatalog.run   s    k 	( 	(F**62299;; ( (CKK'( 	?HNN3X>>>$1%r   c           
     R   g }g }| j         sN| j        r|                    | j        t          j                            | j        | j        d| d          f           |                    t          j                            | j        | j        d| d                     n?t          j        | j                  D ]}t          j                            | j        |d| d          }t          j                            |          rT|                    ||f           |                    t          j                            | j        |d| d                     n|                    | j        | j         f           | j	        r|                    | j	                   nB|                    t          j                            | j        | j        d| d                     |st          d          i }t          |          D ]\  }\  }}||         }t          |d          5 }	t          |	|          }
d d d            n# 1 swxY w Y   | j        ryd}t          |
          dd          D ]}|j        r|dz  }d}t#          |
          r|dz  t#          |
          z  }| j                            d	|t#          |
          ||           |
j        r#| j        s| j                            d
|           t          |
                                          x||
<   }|D ],\  }}|D ]$}| j                            d||j        |           %-| j                            d||           t          |d          5 }t3          ||
| j                   d d d            n# 1 swxY w Y   |S )NLC_MESSAGES.poz.mono message catalogs foundrbr   rN   d   z)%d of %d messages (%d%%) translated in %sz'catalog %s is marked as fuzzy, skippingzerror: %s:%d: %szcompiling catalog %s to %swb)rr   )ro   rq   appendospathjoinrn   listdirexistsrp   r#   	enumerateopenr   ri   r7   stringrw   rY   infofuzzyrr   checkrx   linenor   )rH   rm   po_filesmo_filesrq   po_filecatalogs_and_errorsidxmo_fileinfilecatalog
translatedmessage
percentagecatalog_errorsrz   rx   outfiles                     r    ru   zCompileCatalog._run_domain   s    	>{ F!#dndk.;17nnn"> ">!? @ @ @ T^T[-:06^^^!= != > > > > !j88 F FF gll4>6+8V...J JGw~~g.. F (9::: T^V5B8>^^^)E )E F F FF OOT[$/:;;; > 01111T^T[-:06^^^!= != > > >  	;9::: &/&9&9  	E  	E"C"&'smGgt$$ 2!&&112 2 2 2 2 2 2 2 2 2 2 2 2 2 2  
#G}}QRR0 ( (G~ ("a

w<< B!+c!1S\\!AJ?Gj'  
 } T^ GQQQ<@<Q<QQ(>#1  #  EHNN*GW^U   
 HMM6IIIgt$$ E'T^DDDDE E E E E E E E E E E E E E E #"s$   #I  I	I	6NN	!N	N)
r   r   r   descriptionuser_optionsrV   rB   rO   r{   ru   r   r   r    r[   r[      sz        ?K  L" #L1O     _ _ _& & &F# F# F# F# F#r   r[   c                      fd}|S )zO
    Build a directory_filter function based on a list of ignore patterns.
    c                |    t           j                            |           t          fdD                        S )Nc              3  B   K   | ]}t          j         |          V  d S r-   )fnmatch)r0   ignore_patternbasenames     r    r2   zG_make_directory_filter.<locals>.cli_directory_filter.<locals>.<genexpr>  sC       
 
 OHn55
 
 
 
 
 
r   )r   r   r   any)dirnamer   ignore_patternss    @r    cli_directory_filterz4_make_directory_filter.<locals>.cli_directory_filter  sX    7##G,, 
 
 
 
 
 
 
 
 
 
 	
r   r   )r   r   s   ` r    _make_directory_filterr     s$    

 
 
 
 
  r   c                  b    e Zd ZdZg dZg dZdZdZdddd	d
dZddiZ	d Z
d ZddZd Zd ZdS )ExtractMessagesz1extract localizable strings from the project code))zcharset=Nz3charset to use in the output file (default "utf-8"))z	keywords=kzispace-separated list of keywords to look for in addition to the defaults (may be repeated multiple times))no-default-keywordsNz#do not include the default keywords)zmapping-file=Fz&path to the mapping configuration file)no-locationNz>do not include location comments with filename and line number)zadd-location=Nzlocation lines format. If it is not given or "full", it generates the lines with both file name and line number. If it is "file", the line number part is omitted. If it is "never", it completely suppresses the lines (same as --no-location).)omit-headerNz'do not include msgid "" entry in header)rb   rc   zname of the output filezwidth=wz"set output line width (default 76)no-wrapNzVdo not break long message lines, longer than the output line width, into several lines)sort-outputNz&generate sorted output (default False))sort-by-fileNz,sort output by file location (default False))zmsgid-bugs-address=Nzset report address for msgid)zcopyright-holder=Nzset copyright holder in output)zproject=Nzset project name in output)zversion=Nzset project version in output)zadd-comments=czuplace comment block with TAG (or those preceding keyword lines) in output file. Separate multiple TAGs with commas(,))strip-commentsr1   z)strip the comment TAGs from the comments.)zinput-paths=Nzofiles or directories that should be scanned for messages. Separate multiple files or directories with commas(,))zinput-dirs=Nz@alias for input-paths (does allow files as well as directories).)zignore-dirs=NzwPatterns for directories to ignore when scanning for messages. Separate multiple patterns with spaces (default ".* ._"))zheader-comment=Nzheader comment for the catalog)zlast-translator=Nz7set the name and email of the last translator in output)r   r   r   r   r   r   r   zinput-paths)zadd-commentskeywordszignore-dirs)z	--keyword)z	--mapping)z--output)z--strip-comment-tags)z--last-translator)r   zmapping-filezoutput-filer   zlast-translatorzadd-location)fullfileneverc                V   d| _         d | _        d| _        d | _        d| _        d | _        d| _        d | _        d | _        d | _	        d | _
        d| _        d| _        d| _        d | _        d | _        d | _        d | _        d | _        d| _        d| _        d | _        d | _        d | _        d S )Nzutf-8FT)charsetr   no_default_keywordsmapping_fileno_locationadd_locationomit_headerrp   
input_dirsinput_pathswidthno_wrapsort_outputsort_by_filemsgid_bugs_addresscopyright_holderprojectversionadd_commentsstrip_commentsinclude_linenoignore_dirsheader_commentlast_translatorrL   s    r    rB   z"ExtractMessages.initialize_optionst  s    #(     
 !"& $ #""#r   c                   | j         r#| j        s| j         | _        nt          d          | j        ri nt	          j                    }|                    t          t          | j	                                       || _	        | j	        st          d          | j
        st          d          | j        r| j        rt          d          | j        s| j        sd| _        n | j        t          | j                  | _        | j        r| j        rt          d          | j        r:t!          | j        t"                    rt%          j        d| j                  | _        nV| j        Ht*                              d | j        j        pd	D                                                       | _        ng | _        | j        st          d
          | j        D ]4}t2          j                            |          st          d| d          5t          | j        pd	d          | _        | j        rJ| j        s| j                                        | _        | j        s| j                                         | _        | j!        dk    rd| _"        n| j!        dk    rd| _#        t          | j$                  }|rtK          |          | _&        d S d | _&        d S )Nz1input-dirs and input-paths are mutually exclusivez=you must specify new keywords if you disable the default oneszno output file specified0'--no-wrap' and '--width' are mutually exclusiveL   z;'--sort-output' and '--sort-by-file' are mutually exclusivez,\s*c                F    g | ]}|                     d d          d         S ).rN   r   r*   )r0   r   s     r    
<listcomp>z4ExtractMessages.finalize_options.<locals>.<listcomp>  s9     . . . Q". . .r   r   z'no input files or directories specifiedzInput path: z does not exist,r   Tr   F)'r   r   r#   r   r   copyupdateparse_keywordsr:   r   rp   r   r   intr   r   r4   r5   rer+   rA   dictfromkeyspackageskeysr   r   r   r   r   get_namer   get_versionr   r   r   r   r   directory_filter)rH   r   r   r   s       r    rO   z ExtractMessages.finalize_options  s   ? 	# #'?  !G   1N227G7L7N7N}T]'C'CDDEEE } 	O    	:8999< 	DJ 	B   | 	)DJ 	)DJJZ#TZDJ 	 1 	M    		"$*C00 G#%8GT5E#F#F *#}} . .+4:. . .     tvv 
  "D 	IGHHH$ 	H 	HD7>>$'' H!"F"F"F"FGGGH *$*;*Ar3GG 	?< <#099;;< ?#0<<>>''#D&(("'D#D$455 	)$:;$G$GD!!!$(D!!!r   r   r5   c                     d fd}|S )Nfilenamer5   methodoptionsr   c                   |dk    rd S t           j                                      r}n=t           j                            t           j                            |                     }d}|r7d                    d |                                D                       }d| d}j                            d||           d S )Nignore z, c              3  ,   K   | ]\  }}| d | dV  dS )z=""Nr   )r0   r   vs      r    r2   zDExtractMessages._build_callback.<locals>.callback.<locals>.<genexpr>  s2      &P&P1!||q|||&P&P&P&P&P&Pr   z ()zextracting messages from %s%s)r   r   isfilenormpathr   itemsrY   r   )r   r   r   filepathoptstr
opt_valuesr   rH   s         r    callbackz1ExtractMessages._build_callback.<locals>.callback  s    !! w~~d## J7++BGLLx,H,HIIF ,!YY&P&P&P&P&PPP
+j+++HMM98VLLLLLr   )r   r5   r   r5   r   r   r   )rH   r   r   s   `` r    _build_callbackzExtractMessages._build_callback  s5    	M 	M 	M 	M 	M 	M 	M& r   c                   |                                  }t          | j        d          5 }t          | j        | j        | j        | j        | j        | j	        pt          | j                  }|D ]&\  }}}|                     |          }t          j                            |          r9t          j                    }t#          ||||| j        | j        | j        |          }	n+t+          |||| j        | j        || j        | j                  }	|	D ]\  }
}}}}t          j                            |          r|
}n=t          j                            t          j                            ||
                    }|                    |d ||fg||           (| j                            d| j                   t9          ||| j        | j        | j        | j         | j!        | j"                   d d d            d S # 1 swxY w Y   d S )Nr   )r   r   r   r   r   r   r   )r   comment_tagsr   strip_comment_tagsr   )auto_commentscontextzwriting PO template file to %s)r   r   r   r   r   r   )#_get_mappingsr   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   getcwdr   r   r   r   r   r   r   r   addrY   r   r   r   r   r   r   r   r   )rH   mappingsr   r   r   
method_mapoptions_mapr   current_dir	extractedr   r   r   commentsr   r   s                   r    r{   zExtractMessages.run  st   %%''$"D)) *	9Wdl&*l151H/3/D&*l.2.A.S^.2.BD D DG 2: I I-j+//557>>$'' "$)++K ;j+ $-1B+[! !II !1j+!%%)%6!)+/+>)-)>! ! !I EN I I@Hfgxw~~d++ R#+#%7#3#3BGLLx4P4P#Q#QKK60B/C.6   I I I II HMM:D<LMMMWgTZ!%!1!%!1!%!1"&"3$($79 9 9 9K*	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9 *	9s   G G77G;>G;c                   g }| j         r| j                             d          rtt          | j         d          5 }t          j                            | j                   dk    rdnd}t          || j         |          \  }}d d d            n# 1 swxY w Y   nEt          | j                   5 }t          || j                   \  }}d d d            n# 1 swxY w Y   | j        D ]}|	                    |||f           nt          | j        dd           r| j        j        }|                                D ]}\  }}t          |t                    r t          t!          |                    \  }}n+g i }}|D ]$\  }	}
}|	                    |	|
f           |pi ||	<   %|	                    |||f           ~n'| j        D ]}|	                    |t"          i f            |S )Nz.tomlr   pyproject.toml
standalone)r   styler   message_extractors)r   endswithr   r   r   r   _parse_mapping_tomlparse_mapping_cfgr   r   getattrrA   r  r   r4   r5   r   r   )rH   r  fileobj
file_styler  r  r   r  mappingpatternr   r   s               r    r   zExtractMessages._get_mappings  s    !	= ))'22 e$+T22 
g 7++D,=>>BRRR )() 
 /B!%!2(/ / /+J
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 $+,, e.?RVRc.d.d.d+Je e e e e e e e e e e e e e e( A Az; ?@@@@A T&(<dCC 	=!%!2!E!3!9!9!;!; A Aggs++ =.?@Q@Q.R.R+J.0"J4; = =0"))7F*;<<</6}"G,,z; ?@@@@A ( = = ;<<<<s$   ABBB,CCCN)r   r5   )r   r   r   r   r   rV   rT   rU   rW   rX   rB   rO   r   r{   r   r   r   r    r   r   %  s        EK7 7 7Lp  O G #&$31 N 	1N$ $ $4G) G) G)R   ,,9 ,9 ,9\& & & & &r   r   c                  2    e Zd ZdZg dZdgZd Zd Zd ZdS )InitCatalogz(create a new catalog based on a POT file)r\   r]   z&domain of PO file (default 'messages')r`   )output-dir=r^   zpath to output directoryrb   rc   zQname of the output file (default '<output_dir>/<locale>/LC_MESSAGES/<domain>.po'))re   rf   z$locale for the new localized catalogr   r   r   c                h    d | _         d | _        d | _        d | _        d| _        d| _        d | _        d S rk   )
output_dirrp   ro   rq   rm   r   r   rL   s    r    rB   zInitCatalog.initialize_optionsZ  s8     


r   c                6   | j         st          d          | j        st          d          	 t          j        | j                  | _        n"# t          $ r}t          |          |d }~ww xY w| j        s| j        st          d          | j        s9t          j
                            | j        | j        d| j         d          | _        t          j
                            t          j
                            | j                            s6t          j        t          j
                            | j                             | j        r| j        rt          d          | j        s| j        s	d| _        d S | j        t%          | j                  | _        d S d S )Nyou must specify the input filez-you must provide a locale for the new catalogz%you must specify the output directoryr}   r~   r   r   )ro   r#   rq   r	   parse_localer   rp   r  r   r   r   rm   r   r   makedirsr   r   r   rH   es     r    rO   zInitCatalog.finalize_optionsc  s    	A?@@@{ 	OMNNN	(!<44DLL! 	( 	( 	(a..a'	(  	G 	GEFFF 	P!w||DOT[,9dk;N;N;N P  PD w~~bgood.>??@@ 	;K(899:::< 	RDJ 	RPQQQ| 	)DJ 	)DJJJZ#TZDJJJ $#s   A 
A,A''A,c                   | j                             d| j        | j                   t	          | j        d          5 }t          || j                  }d d d            n# 1 swxY w Y   | j        |_        t          j        	                    t                    |_        d|_        t	          | j        d          5 }t          ||| j                   d d d            d S # 1 swxY w Y   d S )Ncreating catalog %s based on %sr   rq   Fr   )r   )rY   r   rp   ro   r   r   rq   r   datetimenowr   revision_dater   r   r   )rH   r   r   r   s       r    r{   zInitCatalog.run}  sX   -t/?	
 	
 	
 $/4(( 	:F fT[999G	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:
  ( 1 5 5g > >$"D)) 	9WWgTZ8888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s#   AA#&A#;C  C$'C$N	r   r   r   r   r   rV   rB   rO   r{   r   r   r    r  r  D  s`        <K  L$ !kO  ) ) )49 9 9 9 9r   r  c                  4    e Zd ZdZg dZg dZd Zd Zd ZdS )UpdateCatalogz'update message catalogs from a POT file)r  r`   )r  r^   r_   r  )r   Nz%do not include msgid  entry in headerrd   r   r   )zignore-obsolete=Nz1whether to omit obsolete messages from the output)zinit-missing=Nz6if any output files are missing, initialize them first)no-fuzzy-matchingNzdo not use fuzzy matching)update-header-commentNzupdate target header comment)previousNz+keep previous msgids of translated messages)zcheck=Nzdon't update the catalog, just return the status. Return code 0 means nothing would change. Return code 1 means that the catalog would be updated)zignore-pot-creation-date=Nz=ignore changes to POT-Creation-Date when updating or checking)	r   r   zignore-obsoletezinit-missingr-  r0  r/  r   zignore-pot-creation-datec                    d| _         d | _        d | _        d | _        d| _        d | _        d | _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d S rk   )rm   ro   r  rp   r   rq   r   r   ignore_obsoleteinit_missingno_fuzzy_matchingupdate_header_commentr0  r   ignore_pot_creation_daterL   s    r    rB   z UpdateCatalog.initialize_options  sx      
$!!&%*"
(-%%%r   c                J   | j         st          d          | j        s| j        st          d          | j        r| j        st          d          | j        rX| j        st          d          	 t          j        | j                  | _        n)# t          $ r}t          |          |d }~ww xY wd | _        | j
        r| j        rt          d          | j
        s| j        sd| _        n | j        t          | j                  | _        | j        r| j        rd| _        d S d S d S )Nr  z-you must specify the output file or directoryzyou must specify the localez?you must specify the locale for the init-missing option to workr   r   F)ro   r#   rp   r  rq   r3  r	   r  r   r   r   r   r   r4  r0  r"  s     r    rO   zUpdateCatalog.finalize_options  sj    	A?@@@ 	O 	OMNNN 	=DK 	=;<<< 	 ; !6  
,%|DK88% , , ,!!nn!+,  DL< 	RDJ 	RPQQQ| 	)DJ 	)DJJZ#TZDJ! 	"dm 	"!DMMM	" 	" 	" 	"s   /B 
B-B((B-c           
        i }g }| j         s| j        rO|                    | j        t          j                            | j        | j        d| j         d          f           nt          j        | j                  D ]g}t          j                            | j        |d| j         d          }t          j        	                    |          r|                    ||f           hn!|                    | j        | j         f           |st          d          | j        }|sGt          j                            t          j                            | j                            d         }t          | j        d          5 }t          |          }d d d            n# 1 swxY w Y   |D ]\  }}| j        rt          j        	                    |          s| j        rd||<   :| j                            d|| j                   t          | j        d          5 }t          || j                  }	d d d            n# 1 swxY w Y   | j        |	_        t*          j                            t.                    |	_        d|	_        t          |d	          5 }
t5          |
|	           d d d            n# 1 swxY w Y   | j                            d
|| j                   t          |d          5 }t          |||          }	d d d            n# 1 swxY w Y   |	                    || j        | j        | j                    t          j                            t          j                            |          tA          j!                    t          j                            |          z             }	 t          |d	          5 }t5          ||	| j"        | j#        | j$        | j%                   d d d            n# 1 swxY w Y   n## tL          $ r t          j'        |            w xY w| j        rt          |d          5 }t          |          }d d d            n# 1 swxY w Y   t          |d          5 }t          |          }d d d            n# 1 swxY w Y   |j        |_        |(                    |          ||<   t          j'        |           )	 t          j)        ||           A# tT          $ rA t          j'        |           tW          j,        ||           t          j'        |           Y w xY w| j        r|-                                D ]>\  }}|r| j                            d|           #| j        .                    d|           ?t_          |0                                          stc          d          | j                            d           d S d S )Nr}   r~   r   r   r   Fr%  r&  r   zupdating catalog %s based on %s)rq   rm   )r5  update_creation_date)r   r2  include_previousr   zCatalog %s is up to date.zCatalog %s is out of date.zSome catalogs are out of date.z All the catalogs are up-to-date.)2rp   rq   r   r   r   r   r  rm   r   r   r#   splitextr   ro   r   r   r3  r   rY   r   r   r'  r(  r   r)  r   r   r   r4  r5  r6  r   tempfilegettempprefixr   r2  r0  r   	Exceptionremoveis_identicalrenameOSErrorshutilr   r   warningr;   rv   r   )rH   check_statusr   rq   r   rm   r   templater   r   r   tmpnametmpfileorigfileoriginal_catalognewfileupdated_catalog
up_to_dates                     r    r{   zUpdateCatalog.run  s    	={ ;!#dot{.;15.A.A.A"C "C!D E E E E
 !j99 ; ;F gll4?F+8.2k+>+>+>@ @G w~~g.. ; (9:::; OOT[$*:;<<< 	;9::: 	LW%%bg&6&6t&G&GHHKF$/4(( 	'FvH	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' !) @	# @	#FH  /)A)A /: -2L*5x   $/400 BF &fT[AAAGB B B B B B B B B B B B B B B
 "&(0(9(=(=g(F(F% %(D)) /WWg.../ / / / / / / / / / / / / / / HMM;XtWWWh%% H!&GGGH H H H H H H H H H H H H H H NN$0&*&@)-)F%F     gll27??8#<#<#+#9#;#;#%7#3#3H#=#=$>? ?G'4(( OGWg)-)9-1-A.2m4:O O O OO O O O O O O O O O O O O O O
    	'""" z (D)) 9X'.x'8'8$9 9 9 9 9 9 9 9 9 9 9 9 9 9 9'4(( 7G&-g&6&6O7 7 7 7 7 7 7 7 7 7 7 7 7 7 70@0N-)8)E)EFV)W)WX&	'"""
#	'8,,,, # # # 	(###GX...	'"""""# : 
	(4(:(:(<(< M M$* MHMM"=xHHHHH$$%A8LLLL|**,,-- B @AAA@AAAF
	 
	s   ;FFFH77H;	>H;	J++J/	2J/	'LL
	L
	)O;9*O/#O;/O3	3O;6O3	7O;; P5QQ	Q	,RR	R	S%%AT0/T0Nr*  r   r   r    r,  r,    sn        ;K# # #LH  O. . ."" " ">i i i i ir   r,  c                  Z    e Zd ZdZdZde ZdddddZee	e
edZd	Zdd
Zd Zd Zd Zd	S )CommandLineInterfacezCommand-line interface.

    This class provides a simple command-line interface to the message
    extraction and PO file generation functionality.
    z%%prog %s [options] %sz%prog z$compile message catalogs to MO filesz:extract messages from source files and generate a POT filez+create new message catalogs from a POT filez0update existing message catalogs from a POT file)compileextractinitr   Nc                `   |t           j        }t          j        | j        dz  | j                  | _        | j                                         | j        | j        _	        | j        
                    dddd           | j        
                    d	d
ddt          j        d           | j        
                    ddddt          j        d           | j                            dt          j                   | j                            |dd                   \  }}|                     |j                   |j        rtt)          j                    }t-          d |D                       dz   }t/          |          D ]3}t1          j        |          }t5          |d| d|j                    4dS |s| j                            d           |d         }|| j        vr| j                            d| d           |                     ||dd                   }	|	                                S )z{Main entry point of the command-line interface.

        :param argv: list of arguments passed on the command-line
        N)commandz[args])usager   z--list-localeslist_locales
store_truez print all known locales and exit)destactionrF   z-vz	--verbosestore_constloglevelzprint as much as possible)rY  rX  constrF   z-qz--quietzprint as little as possibleF)rV  r[  rN   c              3  4   K   | ]}t          |          V  d S r-   rw   )r0   
identifiers     r    r2   z+CommandLineInterface.run.<locals>.<genexpr>  s(      IIz3z??IIIIIIr   < r   zQno valid command or option passed. Try the -h/--help option for more information.zunknown command "r   ) sysargvoptparseOptionParserrU  r   parserdisable_interspersed_args_help
print_help
add_optionloggingDEBUGERRORset_defaultsINFO
parse_args_configure_loggingr[  rV  r
   locale_identifiersmaxsortedr	   r  printenglish_namerx   commands_configure_commandr{   )
rH   rc  r   argsidentifiersid_widthr_  rq   cmdnamecmdinsts
             r    r{   zCommandLineInterface.runp  sl    <8D+$*?T2T48LB B B--///!%/n&2$F 	 	H 	H 	H 	t[$.gm$? 	 	A 	A 	A 	tY}$.gm$A 	 	C 	C 	C 	  egl KKK..tABBx88 0111 	$799KII[IIIIIAMH$[11 I I
j11GhGGGG&2EGGHHHH1 	PK O P P P q'$-''K<'<<<===))'48<<{{}}r   c                f   t           | _         | j                             |           | j         j        r| j         j        d         }n-t          j                    }| j                             |           |                    |           t          j        d          }|                    |           d S )Nr   z%(message)s)rY   setLevelhandlersrk  StreamHandler
addHandler	FormattersetFormatter)rH   r[  handler	formatters       r    rq  z'CommandLineInterface._configure_logging  s    (### 8 	)h'*GG+--GH((("""%m44	Y'''''r   c                X   t          | j                                                   t          d           t          dt          d | j        D                       dz             }t          | j                                                  D ]\  }}t          d|d| d|            d S )Nz	commands:   c              3  4   K   | ]}t          |          V  d S r-   r^  )r0   rT  s     r    r2   z-CommandLineInterface._help.<locals>.<genexpr>  s(      IIs7||IIIIIIr   rN   z  r`  ra  )ru  rf  format_helprs  rw  rt  r   )rH   	cmd_widthnamer   s       r    rh  zCommandLineInterface._help  s    dk%%''(((k3II4=IIIIIAMNN	!'(;(;(=(=!>!> 	: 	:D+8t8i8888;889999	: 	:r   c                   | j         |         } |            }| j        r| j        |_        t          |t                    sJ |                                 t          j        | j        |dfz  | j        |                   }t          |dd          }|j
        D ]\  }}}	|                    d          }
t          ||
                    dd                    }d|
 g}|r|                    d|            |                    |j                            |
d	                     |j                            |
d          }|
|k    r|xj        d
|
 dz  c_        |
|j        v r |j        |d|	d |
|j        v r |j        |d|	|d  |j        ||	||d |                    |          \  }}|r%t-          ||                    dd          |           t/          |                                          D ]\  }}t-          |||           	 |                                 n9# t4          $ r,}|                    t9          |                     Y d}~nd}~ww xY w|S )zB
        :type cmdname: str
        :type argv: list[str]
        r   )rU  r   rT   N=-_z--r   r`  >rW  )rY  rF   r   )rY  rF   choices)rF   defaultr  )command_classesrY   r4   r?   rB   rd  re  rU  rw  r  r   r/   replacer   r9   rW   getrX   rV   rj  rU   rp  setattrvarsr   rP   r#   rx   r5   )rH   r|  rc  cmdclassr}  rf  rT   longshortrF   r  r  strsr  r   ry  keyvalueerrs                      r    rx  z'CommandLineInterface._configure_command  s   
 '0(**8 	#(GK'<00000""$$$&*},g.
 
 
 &h	4@@!)!6 	V 	VD%::c??Dgt||C'='=>>GKK=D )KKK(((KK/33D"==>>>-11$==GwD+111!!44HHHHH888!!4tWUUUUU!!4dGWUUUUU))$// 	>GW__S#66===w----// 	) 	)JCGS%((((	#$$&&&& 	# 	# 	#LLS""""""""	# s   H, ,
I"6"II"r-   )r   r   r   r(   rU  VERSIONr   rw  r[   r   r  r,  r  rY   r{   rq  rh  rx  r   r   r    rO  rO  W  s          %E w  G9O=D	 H ""	 O C, , , ,\( ( (: : :. . . . .r   rO  c                 X    t                                          t          j                  S r-   )rO  r{   rb  rc  r   r   r    mainr    s    !!%%ch///r   c                Z    t          j        dt          d           t          | |          S )Nz:parse_mapping is deprecated, use parse_mapping_cfg instead   )
stacklevel)warningswarnDeprecationWarningr  )r  r   s     r    parse_mappingr    s6    MD   
 Wh///r   c                   i }g }i }t                      }|                    | |           |                                D ]}|dk    r#t          |                    |                    }+d |                    dd          D             \  }}|                    ||f           t          |                    |                    ||<   |r+t          |          D ]\  }	\  }}||v r||         }||f||	<   ||fS )zParse an extraction method mapping from a file-like object.

    :param fileobj: a readable file-like object containing the configuration
                    text to parse
    :param filename: the name of the file being parsed, for error messages
    
extractorsc              3  >   K   | ]}|                                 V  d S r-   r.   )r0   parts     r    r2   z$parse_mapping_cfg.<locals>.<genexpr>  s*      NNtzz||NNNNNNr   :rN   )r   	read_filesectionsr   r   r+   r   r   )
r  r   r  r  r  rf  sectionr   r  r   s
             r    r  r    s+    JJKF
Wh'''??$$ ? ?l""fll73344JJNNc18M8MNNNOFGw/000#'W(=(=#>#>K   0&/
&;&; 	0 	0"C"'6###F+&/JsOO{""r   	(unknown)r  configr   c          
     (   i }g }i }|                      di           }t          |t                    s!t          | dt	          |                    |                                D ]\\  }}t          |t                    st          | d|          t          |t                    st          | d|          |||<   ]d| v rt          | d          |                      dg           }t          |t                    s!t          | dt	          |                    t          |          D ]Y\  }	}
t          |
t                    s$t          | d	|	 d
t	          |
                    |
	                                }
|

                    dd           }t          |t                    st          | d	|	 d|          |                     ||          }|

                    dd           }t          |t          t          f          st          | d	|	 d|          t          |t                    s|g}|D ]J}t          |t                    st          | d	|	 d|          |                    ||f           |
||<   K[||fS )Nr  z): extractors: Expected a dictionary, got z6: extractors: Extraction method must be a string, got z;: extractors: Callable specification must be a string, got r  z8: 'mapping' is not a valid key, did you mean 'mappings'?r  z!: mappings: Expected a list, got z: mappings[z]: Expected a dictionary, got r   z"]: 'method' must be a string, got r  z-]: 'pattern' must be a list or a string, got z+]: 'pattern' elements must be strings, got )r  r4   r   r'   typer   r5   r7   r   r   popr   )r  r   r  r  r  extractors_readr   callable_specmappings_readr   entryr  pats                r    _parse_config_objectr    s   JJKjjr22Oot,, r H!p!pW[\kWlWl!p!pqqq!0!6!6!8!8 + +&#&& 	t$%r%rhn%r%rsss--- 	@$%~%~mz%~%~*
6F H!f!f!fgggJJz2..MmT** h H!f!ftTaObOb!f!fggg.. % %
U%&& 	q$%o%oS%o%o`dej`k`k%o%oppp

8T**&#&& 	p$%n%nS%n%ndj%n%nooo//))It,,'D#;// 	|$%z%zS%z%zov%z%z{{{'4(( 	 iG 	% 	%Cc3'' z(H)x)x)x)xqt)x)xyyysFm,,,$K		% {""r   r
  r  r   r   r5   r  'Literal['standalone', 'pyproject.toml']c                   	 ddl }n8# t          $ r+ 	 ddl}n"# t          $ r}t          d          |d}~ww xY wY nw xY w	 |                    |           }n'# |j        $ r}t          | d|           |d}~ww xY w|dk    r<	 |d         d         }n]# t          t          f$ r}t          | d          |d}~ww xY w|d	k    r|}d|v rt          | d
          nt          d|          t          ||          S )a  Parse an extraction method mapping from a binary file-like object.

    .. warning: As of this version of Babel, this is a private API subject to changes.

    :param fileobj: a readable binary file-like object containing the configuration TOML to parse
    :param filename: the name of the file being parsed, for error messages
    :param style: whether the file is in the style of a `pyproject.toml` file, i.e. whether to look for `tool.babel`.
    r   Nz0tomli or tomllib is required to parse TOML filesz: Error parsing TOML file: r	  toolr   z': No 'tool.babel' section found in filer
  zC: 'babel' should not be present in a stand-alone configuration filezUnknown TOML style r  )
tomllibImportErrortomliloadTOMLDecodeErrorr'   	TypeErrorKeyError
ValueErrorr  )r  r   r  r  ieparsed_datar#  
babel_datas           r    r  r  @  s   Z Z Z Z	Z##### 	Z 	Z 	ZPQQWYY	Z $#ZUll7++" U U U H!L!L!L!LMMSTTU    	b$V,W5JJ8$ 	b 	b 	b$%Y%Y%YZZ`aa	b	,		 
j  $%u%u%uvvv ! 8u88999
X>>>>sT    
<<
616<< A 
A: A55A:B B<$B77B<r1   return4tuple[int | None, tuple[int | tuple[int, str], ...]]c                Z   g }d }|                      d          D ]}|d         dk    rt          |d d                   }&|d         dk    r-|                    t          |d d                   df           _|                    t          |                     |t          |          fS )Nr   tr   )r+   r   r   r8   )r1   indsnumberxs       r    _parse_specr  i  s    DFWWS\\    R5C<<3B3[[FFrUc\\KKQssVc*++++KKA5;;r   r   stringsIterable[str]c                "   i }| D ]P}d|v r+|                     d          \  }}t          |          \  }}n|}d}d}||                    |i           |<   Q|                                D ]$\  }}t	          |          dhk    r|d         ||<   %|S )a  Parse keywords specifications from the given list of strings.

    >>> import pprint
    >>> keywords = ['_', 'dgettext:2', 'dngettext:2,3', 'pgettext:1c,2',
    ...             'polymorphic:1', 'polymorphic:2,2t', 'polymorphic:3c,3t']
    >>> pprint.pprint(parse_keywords(keywords))
    {'_': None,
     'dgettext': (2,),
     'dngettext': (2, 3),
     'pgettext': ((1, 'c'), 2),
     'polymorphic': {None: (1,), 2: (2,), 3: ((3, 'c'),)}}

    The input keywords are in GNU Gettext style; see :doc:`cmdline` for details.

    The output is a dictionary mapping keyword names to a dictionary of specifications.
    Keys in this dictionary are numbers of arguments, where ``None`` means that all numbers
    of arguments are matched, and a number means only calls with that number of arguments
    are matched (which happens when using the "t" specifier). However, as a special
    case for backwards compatibility, if the dictionary of specifications would
    be ``{None: x}``, i.e., there is only one specification and it matches all argument
    counts, then it is collapsed into just ``x``.

    A specification is either a tuple or None. If a tuple, each element can be either a number
    ``n``, meaning that the nth argument should be extracted as a message, or the tuple
    ``(n, 'c')``, meaning that the nth argument should be extracted as context for the
    messages. A ``None`` specification is equivalent to ``(1,)``, extracting the first
    argument.
    r  N)r+   r  
setdefaultr   set)	r  r   r   funcnamespec_strr  specr   r   s	            r    r   r   v  s    : H 9 9&==!'c!2!2Hh&x00LFDDHFD48Hb))&11    " "1q66dVD'HQKOr   r  c                j    | dv rddl m} t          ||           S t          dt          d|           )N>   init_catalogupdate_catalogcompile_catalogextract_messagescheck_message_extractorsr   )setuptools_frontendzmodule z has no attribute )babel.messagesr  r  AttributeErrorr   )r  r  s     r    __getattr__r    sR     ttt666666*D111
I8IIII
J
JJr   __main__r-   )r  r   )r  r
  )r  r   r   r5   r  r  )r1   r5   r  r  )r   )r  r  )r  r5   )Cr(   
__future__r   r'  r   rk  rd  r   r   rC  rb  r<  r  configparserr   ior   typingr   r   r   r   r	   r
   r   r  
babel.corer   babel.messages.catalogr   r   babel.messages.extractr   r   r   r   babel.messages.mofiler   babel.messages.pofiler   r   
babel.utilr   	getLoggerrY   r>  r   r#   r%   r'   r:   r?   r[   r   r   r  r,  rO  r  r  r  r  r  r  r   r  r   r   r   r    <module>r     sx    # " " " " "     				 				  



   ( ( ( ( ( (       . . . . . . . . . . $ $ $ $ $ $ $ $ ( ( ( ( ( ( ) ) ) ) ) ) : : : : : : : :            + * * * * * 3 3 3 3 3 3 3 3      g  	 	 	 	 		 	 	 		 	 	 	 	) 	 	 		 	 	 	 	 	 	 	       ' ' ' 'T3
 3
 3
 3
 3
 3
 3
 3
lt# t# t# t# t#\ t# t# t#n      \ \ \ \ \l \ \ \~H9 H9 H9 H9 H9, H9 H9 H9VE E E E EL E E EPK K K K K K K K\0 0 00 0 0 0# # # #> 4? ,# ,# ,# ,# ,# ,#b  5A&? &? &? &? &?R
 
 
 
- - - - -`K K K K zDFFFFF r   