AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.133.127.195
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python2.7/site-packages/babel/messages/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /lib/python2.7/site-packages/babel/messages/extract.pyc
�
��Mc@s|dZddlZyeWn!ek
r=ddlmZnXddlZddlmZm	Z	m
Z
mZmZddl
mZmZmZddlmZddd	gZd
ZdZidd6dd
6d!d6dd6d"d6d#d6d$d6dd6Zd%gZdZd�Zej�eded&ded�Zed'ded�Zed(ded�Zd�Z d�Z!d �Z"dS()s�Basic infrastructure for extracting localizable messages from source files.

This module defines an extensible system for collecting localizable message
strings from a variety of sources. A native extractor for Python source files
is builtin, extractors for other sources can be added using very simple plugins.

The main entry points into the extraction functionality are the functions
`extract_from_dir` and `extract_from_file`.
i����N(tSet(tgenerate_tokenstCOMMENTtNAMEtOPtSTRING(tparse_encodingt	pathmatchtrelpath(tdedenttextracttextract_from_dirtextract_from_filesrestructuredtext ensbabel.extractorst_tgettextiitngettexttugettextt	ungettexttdgettextit	dngettexttN_s**.pytpythons�%s: warning: Empty msgid.  It is reserved by GNU gettext: gettext("") returns the header entry with meta information, not the empty string.cs#�fd�}t||�|(dS(s�Helper function for `extract` that strips comment tags from strings
    in a list of comment lines.  This functions operates in-place.
    cs8x1�D])}|j|�r|t|�j�SqW|S(N(t
startswithtlentstrip(tlinettag(ttags(s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyt_strip>s
N(tmap(tcommentsRR((Rs:/usr/lib/python2.7/site-packages/babel/messages/extract.pyt_strip_comment_tags:sccs�|dkri}ntjj|�}x�tj|�D]\}}	}
x<|	D]4}|jd�sq|jd�rM|	j|�qMqMW|	j�|
j�x|
D]}ttjj	||�j
tjd�|�}x�|D]�\}
}t|
|�r�tjj	||�}i}x2|j
�D]$\}}t||�r|}qqW|r^||||�nxIt||d|d|d|d|�D] \}}}||||fVq�WPq�q�Wq�Wq7WdS(	sRExtract messages from any source files found in the given directory.

    This function generates tuples of the form:

        ``(filename, lineno, message, comments)``

    Which extraction method is used per file is determined by the `method_map`
    parameter, which maps extended glob patterns to extraction method names.
    For example, the following is the default mapping:

    >>> method_map = [
    ...     ('**.py', 'python')
    ... ]

    This basically says that files with the filename extension ".py" at any
    level inside the directory should be processed by the "python" extraction
    method. Files that don't match any of the mapping patterns are ignored. See
    the documentation of the `pathmatch` function for details on the pattern
    syntax.

    The following extended mapping would also use the "genshi" extraction
    method on any file in "templates" subdirectory:

    >>> method_map = [
    ...     ('**/templates/**.*', 'genshi'),
    ...     ('**.py', 'python')
    ... ]

    The dictionary provided by the optional `options_map` parameter augments
    these mappings. It uses extended glob patterns as keys, and the values are
    dictionaries mapping options names to option values (both strings).

    The glob patterns of the `options_map` do not necessarily need to be the
    same as those used in the method mapping. For example, while all files in
    the ``templates`` folders in an application may be Genshi applications, the
    options for those files may differ based on extension:

    >>> options_map = {
    ...     '**/templates/**.txt': {
    ...         'template_class': 'genshi.template:TextTemplate',
    ...         'encoding': 'latin-1'
    ...     },
    ...     '**/templates/**.html': {
    ...         'include_attrs': ''
    ...     }
    ... }

    :param dirname: the path to the directory to extract messages from
    :param method_map: a list of ``(pattern, method)`` tuples that maps of
                       extraction method names to extended glob patterns
    :param options_map: a dictionary of additional options (optional)
    :param keywords: a dictionary mapping keywords (i.e. names of functions
                     that should be recognized as translation functions) to
                     tuples that specify which of their arguments contain
                     localizable strings
    :param comment_tags: a list of tags of translator comments to search for
                         and include in the results
    :param callback: a function that is called for every file that message are
                     extracted from, just before the extraction itself is
                     performed; the function is passed the filename, the name
                     of the extraction method and and the options dictionary as
                     positional arguments, in that order
    :param strip_comment_tags: a flag that if set to `True` causes all comment
                               tags to be removed from the collected comments.
    :return: an iterator over ``(filename, lineno, funcname, message)`` tuples
    :rtype: ``iterator``
    :see: `pathmatch`
    t.R
t/tkeywordstcomment_tagstoptionststrip_comment_tagsN(tNonetostpathtabspathtwalkRtremovetsortRtjointreplacetsepRtitemsR(tdirnamet
method_maptoptions_mapR"R#tcallbackR%tabsnametroottdirnamest	filenamestsubdirtfilenametpatterntmethodtfilepathR$topatterntodicttlinenotmessageR((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyRFs<G	



!	
cCsDt|d�}z#tt||||||��SWd|j�XdS(s�Extract messages from a specific file.

    This function returns a list of tuples of the form:

        ``(lineno, funcname, message)``

    :param filename: the path to the file to extract messages from
    :param method: a string specifying the extraction method (.e.g. "python")
    :param keywords: a dictionary mapping keywords (i.e. names of functions
                     that should be recognized as translation functions) to
                     tuples that specify which of their arguments contain
                     localizable strings
    :param comment_tags: a list of translator tags to search for and include
                         in the results
    :param strip_comment_tags: a flag that if set to `True` causes all comment
                               tags to be removed from the collected comments.
    :param options: a dictionary of additional options (optional)
    :return: the list of extracted messages
    :rtype: `list`
    tUN(topentlistR
tclose(R<R:R"R#R$R%tfileobj((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyR�s
c
cs�d}d|ksd|kr�d|krU|jd�}|| ||d}}	n|jdd�\}}	tt|ii|	g�|	�}n{yddlm}
Wn4tk
r�itd6t	d6}|j
|�}n1Xx-|
jt|�D]}|j
dt�}Pq�W|dkr+td	|��n|||j�|d
|pIi�}
x�|
D]�\}}}}|r�||p{d}nd}t|ttf�s�|g}n|s�qVng}t}t|�}xU|D]M}||kr�t}Pn||d}|dkrt}Pn|j|�q�W|r0qVn|dd}||s�dt|d
�rc|jpfd|f}tjt|IJqVnt|�}t|�dkr�|d}n|r�t||�n|||fVqVWdS(sExtract messages from the given file-like object using the specified
    extraction method.

    This function returns a list of tuples of the form:

        ``(lineno, message, comments)``

    The implementation dispatches the actual extraction to plugins, based on the
    value of the ``method`` parameter.

    >>> source = '''# foo module
    ... def run(argv):
    ...    print _('Hello, world!')
    ... '''

    >>> from StringIO import StringIO
    >>> for message in extract('python', StringIO(source)):
    ...     print message
    (3, u'Hello, world!', [])

    :param method: a string specifying the extraction method (.e.g. "python");
                   if this is a simple name, the extraction function will be
                   looked up by entry point; if it is an explicit reference
                   to a function (of the form ``package.module:funcname`` or
                   ``package.module.funcname``), the corresponding function
                   will be imported and used
    :param fileobj: the file-like object the messages should be extracted from
    :param keywords: a dictionary mapping keywords (i.e. names of functions
                     that should be recognized as translation functions) to
                     tuples that specify which of their arguments contain
                     localizable strings
    :param comment_tags: a list of translator tags to search for and include
                         in the results
    :param options: a dictionary of additional options (optional)
    :param strip_comment_tags: a flag that if set to `True` causes all comment
                               tags to be removed from the collected comments.
    :return: the list of extracted messages
    :rtype: `list`
    :raise ValueError: if the extraction method is not registered
    t:R ii����(tworking_settignoreRtrequiresUnknown extraction method %rR$is%s:%itnames	(unknown)N(i(i(R&trfindtsplittgetattrt
__import__t
pkg_resourcesRHtImportErrortextract_nothingtextract_pythontgettiter_entry_pointst
GROUP_NAMEtloadtTruet
ValueErrortkeyst
isinstanceRDttupletFalseRtappendthasattrRKtsyststderrtempty_msgid_warningR(R<RFR"R#R$R%tfunctlastdottmoduletattrnameRHtbuiltintentry_pointtresultsR@tfuncnametmessagesRtspectmsgstinvalidt
last_indextindexRAtfirst_msg_indextwhere((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyR
�sl*$




cCsgS(sdPseudo extractor that does not actually extract anything, but simply
    returns an empty list.
    ((RFR"R#R$((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyRR@sccsd}}}d}g}g}	g}
t}}d}
t|�pQ|jdd�}t|j�}x�|D]�\}}\}}}}|dkr�|tkr�|dkr�t}qj|tkr�|dkr�|r�t}qjn|r|}|d7}qqj|r"|tkr"|dkr"t}qjqj|dkr�|t	kr�|j
|�dj�}|r�|
dd	|dkr�|
j||f�qjnx�|D]2}
|j
|
�r�t}|
j||f�Pq�q�Wqj|r�|d	kr�|tkr�|d
kr�|r|	jdj|��|2n
|	jd�t|	�dkrEt|	�}	n
|	d	}	|
rv|
dd	|dkrvg}
n|||	g|
D]}|d^q�fVd}}}d}g}	g}
t}q|tkr'td||fiid
6i�}t|t�r|j
|�}n|j|�q|tkr|dkr|rb|	jdj|��|2n
|	jd�|
r�|
j�\}}|
j|d|f�q�qqj|d	kr�|tkr�|d
kr�|d8}qj|r�|dkr�d}qj|tkrj||krj|}qjqjWdS(sAExtract messages from Python source code.

    :param fileobj: the seekable, file-like object the messages should be
                    extracted from
    :param keywords: a list of keywords (i.e. function names) that should be
                     recognized as translation functions
    :param comment_tags: a list of translator tags to search for and include
                         in the results
    :param options: a dictionary of additional options (optional)
    :return: an iterator over ``(lineno, funcname, message, comments)`` tuples
    :rtype: ``iterator``
    i����tencodings
iso-8859-1tdeftclasst(iRGit)ts# coding=%s
%st__builtins__t,N(RtRu(R&R]RRTRtreadlineRRXRRtdecodeRR^RR-RR\RtevalR[tstrtpop(RFR"R#R$RjR@tmessage_linenot
call_stacktbufRkttranslator_commentstin_deftin_translator_commentstcomment_tagRsttokensttoktvalueR
tcommentt
old_linenotold_comment((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyRSGs�

"$	


			
 $
	ccs�ddlm}m}d}}g}d}	g}
t}|jdd�}d}
d}xb||j�j|��D]E}|jdkr�|j	dkr�|r�|j
}|d7}q�n�|dkrc|jdkrc|j	d	j�}|
r |
dd
|j
dkr |
j|j
|f�qrnx�|D]5}|j
|�r'|
j|j
|j�f�Pq'q'WnN|jdkr8g}
|j	d	d!j�}x |D]�}|j
|�r�|j�}|r-|d
j�|d
<td
j|d��j�|d)x7t|�D]&\}}|
j|j
||f�qWnPq�q�Wny|r�|d
kr�|jdkrE|j	dkrE|	dk	r�|j|	�nt|�dkr�t|�}n|r�|d
}nd}|
r�|
dd
|dkr�g}
n|dk	r|||g|
D]}|d^qfVnd}}}	t}g}
g}d}q�|jdkr�||j	�}|r�|	prd|}	t}q�|}	q�|jdkr�|j	dkr�|	dk	r�|j|	�d}	n
|jd�t}q�|j	dkr�t}q�q�n�|d
kr6|jdkr6|j	dkr6|d8}n{|rQ|dkrQd}n`|dkr�|jdkr�|j	|kr�|
dks�|
jdks�|
j	dkr�|j	}n|}
qrWdS(sEExtract messages from JavaScript source code.

    :param fileobj: the seekable, file-like object the messages should be
                    extracted from
    :param keywords: a list of keywords (i.e. function names) that should be
                     recognized as translation functions
    :param comment_tags: a list of translator tags to search for and include
                         in the results
    :param options: a dictionary of additional options (optional)
    :return: an iterator over ``(lineno, funcname, message, comments)`` tuples
    :rtype: ``iterator``
    i����(ttokenizetunquote_stringRssutf-8toperatorRvitlinecommentiitmultilinecommenti����s
RwtstringRxRzt+RKtfunctionN(tbabel.messages.jslexerR�R�R&R]RTtreadR|ttypeR�R@RR^Rt
splitlinesR	R-t	enumerateRR\RX(RFR"R#R$R�R�RjR�Rkt
last_argumentR�tconcatenate_nextRst
last_tokenR�ttokenR�R�tlinestoffsetRR�t	new_value((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pytextract_javascript�s�

"	

#
		"			
	
	
	(ii(ii(i(ii(s**.pyspython((((#t__doc__R'tsett	NameErrortsetsRR`R�RRRRRt
babel.utilRRRttextwrapR	t__all__t
__docformat__RVR&tDEFAULT_KEYWORDStDEFAULT_MAPPINGRbRtgetcwdR]RRR
RRRSR�(((s:/usr/lib/python2.7/site-packages/babel/messages/extract.pyt<module>sD
(
		hq		p

Anon7 - 2022
AnonSec Team