%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/babel/messages/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/babel/messages/__pycache__/extract.cpython-312.pyc

�

ƪb�g����dZddlZddlmZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZddlmZdZdddddd	d
dddd
�
ZdgZdZd�Zd�Zdededdddfd�Z	dd�Zedddfd�Zedddfd�Zd�Zd�Zd�Zy)af
    babel.messages.extract
    ~~~~~~~~~~~~~~~~~~~~~~

    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`.

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�relpath)�generate_tokens�COMMENT�NAME�OP�STRING)�parse_encoding�parse_future_flags�	pathmatch)�dedentzbabel.extractors)��)r)r�)�r
�cr)rrr)
�_�gettext�ngettext�ugettext�	ungettext�dgettext�	dngettext�N_�pgettext�	npgettext)z**.py�pythonz�%s: warning: Empty msgid.  It is reserved by GNU gettext: gettext("") returns the header entry with meta information, not the empty string.c�.���fd�}t||�|ddy)z�Helper function for `extract` that strips comment tags from strings
    in a list of comment lines.  This functions operates in-place.
    c�t���D]1}|j|�s�|t|�dj�cS|S�N)�
startswith�len�strip)�line�tag�tagss  ��8/usr/lib/python3/dist-packages/babel/messages/extract.py�_stripz#_strip_comment_tags.<locals>._strip6s>����	/�C����s�#��C��H�I��,�,�.�.�	/���N)�map)�commentsr%r's ` r&�_strip_comment_tagsr+2s����
�f�h�'�H�Q�Kr(c��tjj|�}|jd�xs|jd�S)N�.r)�os�path�basenamer )�dirpath�subdirs  r&�default_directory_filterr3>s:��
�W�W�
�
�g�
&�F��!�!�#�&�@�&�*;�*;�C�*@�A�Ar(�Fc#�JK�|�tj�}|�i}|�t}tjj	|�}tj
|�D]�\}	}
}|
D�cgc]*}|tjj
|	|��r|��,c}|
dd|
j�|j�|D][}
tjj
|	|
�jtjd�}t||||||||��Ed{����]��ycc}w7��w)a$
Extract messages from any source files found in the given directory.

    This function generates tuples of the form ``(filename, lineno, message,
    comments, context)``.

    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.  If
                    not given the current working directory is used.
    :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.
    :param directory_filter: a callback to determine whether a directory should
                             be recursed into. Receives the full directory path;
                             should return True if the directory is valid.
    :see: `pathmatch`
    N�/)r1)r.�getcwdr3r/�abspath�walk�join�sort�replace�sep�check_and_call_extract_file)�dirname�
method_map�options_map�keywords�comment_tags�callback�strip_comment_tags�directory_filter�absname�root�dirnames�	filenamesr2�filename�filepaths               r&�extract_from_dirrMDs����^���)�)�+��������3���g�g�o�o�g�&�G�%'�W�W�W�%5��!��h�	�!)�
��������T�6� :�;�
�
����	�
�
������!�	�H��w�w�|�|�D�(�3�;�;�B�F�F�C�H�H�2�������"��	�	
�	
�	���
�	
�s�A"D#�$/D�A?D#�D!�D#c	#�K�t||�}|D]f\}	}
t|	|�s�i}|j�D]\}}
t||�s�|
}�|r
|||
|�t|
|||||��D]
}|f|z���yy�w)aChecks if the given file matches an extraction method mapping, and if so, calls extract_from_file.

    Note that the extraction method mappings are based relative to dirpath.
    So, given an absolute path to a file `filepath`, we want to check using
    just the relative path from `dirpath` to `filepath`.

    Yields 5-tuples (filename, lineno, messages, comments, context).

    :param filepath: An absolute path to a file that exists.
    :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 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 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 strip_comment_tags: a flag that if set to `True` causes all comment
                               tags to be removed from the collected comments.
    :param dirpath: the path to the directory to extract messages from.
    :return: iterable of 5-tuples (filename, lineno, messages, comments, context)
    :rtype: Iterable[tuple[str, int, str|tuple[str], list[str], str|None]
    )rBrC�optionsrEN)rr�items�extract_from_file)rLr@rArDrBrCrEr1rK�pattern�methodrO�opattern�odict�
message_tuples               r&r>r>�s�����B�x��)�H�%�������(�+����*�0�0�2�	 �O�H�e���8�,���	 ���X�v�w�/�.��H��%��1�
�	/�M��,��.�.�	/�	�'�s�AA;�	2A;c��|dk(rgSt|d�5}tt||||||��cddd�S#1swYyxYw)aExtract messages from a specific file.

    This function returns a list of tuples of the form ``(lineno, message, comments, context)``.

    :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)
    :returns: list of tuples of the form ``(lineno, message, comments, context)``
    :rtype: list[tuple[int, str|tuple[str], list[str], str|None]
    �ignore�rbN)�open�list�extract)rSrKrBrCrOrE�fileobjs       r&rQrQ�sO��(����	�	
�h��	�:���G�F�G�X�|�#�%7�9�:�:�:�:�s	�7�Ac#�K�d}t|�r|}n�d|vsd|vrRd|vr|jd�}|d|||dzd}	}n|jdd�\}}	tt	|ii|	g�|	�}n[	ddlm}
|
jt|�D]}|jd��}n	|�#tttd	�}|j|�}|�td
|z��|||j!�||xsi��}
|
D�]<\}}}}|r
||xsd}nd}t#|t$t&f�s|g}|s�3d}g}d
}t)|�}|D]F}t#|t&�r||ddz
}�||krd}n!||dz
}|�d}n|j+|��H|r��t#|dt&�r	|ddz
}n|ddz
}||sNdt-|d�xr|j.xsd|fz}t0j2j5t6|zdz���	t'|�}t)|�dk(r|d}|rt9||�||||f����?y#t$rY���wxYw�w)a�Extract messages from the given file-like object using the specified
    extraction method.

    This function returns tuples of the form ``(lineno, message, comments, context)``.

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

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

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

    :param method: an extraction method (a callable), or
                   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.
    :raise ValueError: if the extraction method is not registered
    :returns: iterable of tuples of the form ``(lineno, message, comments, context)``
    :rtype: Iterable[tuple[int, str|tuple[str], list[str], str|None]
    N�:r-r
r)�working_setT)�require)rXr�
javascriptzUnknown extraction method %r)rO)r
Fz%s:%i�namez	(unknown)�
)�callable�rfind�split�getattr�
__import__�
pkg_resourcesr`�iter_entry_points�
GROUP_NAME�load�ImportError�extract_nothing�extract_python�extract_javascript�get�
ValueError�keys�
isinstancer[�tupler!�append�hasattrrc�sys�stderr�write�empty_msgid_warningr+)rSr]rBrCrOrE�func�lastdot�module�attrnamer`�entry_point�builtin�results�lineno�funcname�messagesr*�spec�context�msgs�invalid�
last_index�index�message�first_msg_index�wheres                           r&r\r\s�����R�D������	���#��-��f���l�l�3�'�G�%�h�w�/���!���1E�H�F�%�|�|�C��3��F�H��z�&�"�b�8�*�=�x�H��	�1� +�<�<�Z�=C� E�
��"�'�'��'�5���
��<�
*�(�0��G�
�;�;�v�&�D��|��7�&�@�A�A��7�H�M�M�O�\�"�=�b�*�G�18�32�,���(�H���H�%�-��D��D��(�T�5�M�2� �z�H�����������]�
��	!�E��%��'�"�5��8�a�<�0����E�!�����u�q�y�)�G�������K�K�� �	!����d�1�g�u�%�"�1�g��k�O�"�1�g��k�O���(��w�w��7� ,�&�|�|� ;�/:�F�D�D�E��J�J���1�E�9�T�A�B����;���x�=�A����{�H����,�7��h��'�1�1�g32��1�	��	�s+�A+I	�.H9�4GI	�9	I�I	�I�I	c��gS)zdPseudo extractor that does not actually extract anything, but simply
    returns an empty list.
    r4)r]rBrCrOs    r&roro�s	���Ir(c	#����K�dx}x}}d}g}g}	g}
dx}}d}
t��xs|jdd��t���}��fd�}t|�}|D�]�\}}\}}}}|dk(r|tk(r|dvrd}�"|t
k(r|d	k(r|rd}�5|s�8|}|d
z
}�@|r|t
k(r|dk(rd}�S|dk(rp|tk(rg|d
dj�}|r"|
dd|d
z
k(r|
j||f���|D]*}
|j|
�s�d}|
j||f�����|�r�|dk(�rz|tk(xr||v}|t
k(r|d
k(s|r�|r&|	jdj|��|dd�=n|	jd�t|	�d
kDrt|	�}	n|	d}	|
r|
dd|d
z
krg}
|||	|
D�cgc]}|d
��	c}f��dx}x}}d}g}	g}
d}|s���|}���|tk(r?tdt���d|��dd|�}t!|diii�}|j|����|t
k(s���|dk(s���|r&|	jdj|��|dd�=n|	jd�|
s�� |
j#�\}}|
j|d
z|f���K|dkDr|t
k(r|d
k(r|d
z}��e|r	|dk(rd}��p|tk(s��{||vs���|}���ycc}w�w)acExtract messages from Python source code.

    It returns an iterator yielding tuples in the following form ``(lineno,
    funcname, message, comments)``.

    :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)
    :rtype: ``iterator``
    N���F�encodingzUTF-8c�B���j�j��Sr)�readline�decode)r�r]s��r&�<lambda>z extract_python.<locals>.<lambda>�s����(�(�*�1�1�(�;�r()�def�classT�(r
r_r�)�z	# coding=rdz<string>�eval�__builtins__�,)r	rrr
rrrrr"rwr r:r!rvr�compile�strr��pop)r]rBrCrOr�r��message_lineno�
call_stack�bufr��translator_comments�in_def�in_translator_comments�comment_tag�future_flags�	next_line�tokens�tok�valuer�nested�comment�code�
old_lineno�old_commentr�s`                        @r&rprp�sT�����*.�-�H�-�v���J�
�C��H���&+�+�F�
#��K��g�&�J�'�+�+�j�'�*J�H�%�g�x�8�L�;�I�
�Y�
'�F�)/�W�%��U�K�V�Q��A�����t���9I�0I��F�
�B�Y�5�C�<������!'���a��
�
��r�	�e�s�l��F��
�2�
�#��.��!�"�I�O�O�%�E�%�'��+�A�.�&�1�*�<�#�*�*�F�E�?�;�� ,�
���#�#�K�0�-1�*�'�.�.����?��	
�
�*��/��T�k�7�e�x�&7�F��r�	�e�s�l�v���O�O�B�G�G�C�L�1��A���O�O�D�)��x�=�1�$�$�X��H�'��{�H�'�+�B�/��2�^�a�5G�G�*,�'�%�x��2E�F�w���
�F�H�H�6:�9��9�6�N��
���&(�#�).�&��$�H����
�C��M�5�I�)�6�<�A���T�N�B�#7��<���
�
�5�!����u��|���O�O�B�G�G�C�L�1��A���O�O�D�)�&�
/B�.E�.E�.G�+�J��'�.�.�
�Q���/L�M�
�!�^��r�	�e�s�l��!�O�J�
�*��*��H�
�D�[�U�h�.��H�oW��fG�sF�B
K#�A6K#�B2K#�8K�K#�AK#�3K#�:;K#�7AK#�K#�K#c	#�K�ddlm}m}m}dx}}g}	d}
g}d}|j	dd�}
d}d}td�|D��}||j
�j|
�|j	d	d
�|j	dd
�|��D�]�}|rU|rS|jd
k(rD|jdk(r5|j}||j�g}	d}|dd|j�}|jdk(r%|jdk(r|�r?|j}|dz
}�n,|dk(r�|jdk(r�|jddj�}|r6|dd|jdz
k(r|j|j|f���|D]A}|j|�s�|j|j|j�f��n~�n{|jdk(r�g}|jddj�}|D]�}|j|�s�|j�}|rw|dj�|d<tdj!|dd��j�|ddt#|�D]%\}}|j|j|z|f��'�n��n�|�r#|dk(�r|jdk(r�|jdk(rt|
�|	j|
�t%|	�dkDrt'|	�}	n
|	r|	d}	nd}	|r|dd|dz
krg}|	�|||	|D�cgc]}|d��	c}f��dx}x}}
d}g}g}	d}�n|jdvr#||j�}|r|
xsd|z}
d}n�|}
n�|jdk(r�|jdk(r*|
�|	j|
�d}
n|	jd�d}n�|jdk(r�d
}n�|dkDr$|jdk(r|jdk(r|dz}nX|r|dk(rd}nN|dk(rI|jd
k(r:|j|vr,|�|jd
k7s|jdk7r|j}|}���ycc}w�w)a�Extract 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)
                    Supported options are:
                    * `jsx` -- set to false to disable JSX/E4X support.
                    * `template_string` -- set to false to disable ES6 template string support.
    r)�Token�tokenize�unquote_stringNFr�zutf-8r�c3�$K�|]}d|v���
y�w)r-Nr4)�.0�kws  r&�	<genexpr>z%extract_javascript.<locals>.<genexpr>s����.�r����.�s��jsxT�template_string)r�r��dottedrc�operatorr�r�r
�linecommentr�multilinecomment���rd)�stringr�r�r��+�function)�babel.messages.jslexerr�r�r�rr�any�readr��typer�r�r"rwr �
splitlinesrr:�	enumerater!rv)r]rBrCrOr�r�r�r�r�r��
last_argumentr��concatenate_nextr��
last_tokenr�r��tokenr�r��lines�offsetr#r��	new_values                         r&rqrqsz����G�F� $�$�H�~��H��M������{�{�:�w�/�H��J��J�
�.�X�.�
.�F��������h�'��K�K��t�$����$5�t�<��	�k��
�
�J�O�O�v�5��J�J�+�+�"�\�\�N�&�u�{�{�3�4�H��J��*�c�5�<�<�8�E��:�:��#����s�(:��!&�����a��
�
�2�
�%�*�*�
�"=��K�K���O�)�)�+�E�"�"�2�&�q�)�U�\�\�A�-=�=�#�*�*�E�L�L�%�+@�A��+�
���#�#�K�0�'�.�.����e�k�k�m�/L�M��
�
�Z�Z�-�
-�"$���K�K��"�%�+�+�-�E�+�	
���#�#�K�0�!�,�,�.�E��#(��8�>�>�#3��a��$*�4�9�9�U�1�2�Y�+?�$@�$K�$K�$M��a�b�	�,5�e�,<�?�L�F�D�/�6�6����v�8M�8<�8>�?�?��	
��*��/��z�z�Z�'�E�K�K�3�,>� �,��O�O�M�2��x�=�1�$�$�X��H��'��{�H�#�H�'�&�r�*�1�-���0B�B�*,�'��'�)�8�X�6I�J�7�G�A�J�J�L�L�=A�@��@�>�M�#(� �&(�#����
����<�<�*�5�;�;�7�	�#�%2�%8�b�I�$E�M�',�$�$-�M����z�)��;�;�#�%�$�0� ���
�6�(,�
� ����-�',�$��[�[�C�'�'+�$�
�!�^��
�
�j� 8��K�K�3�&��!�O�J�
�*��*��H�
�2�
�%�*�*��"6��K�K�8�#�
�
�:�?�?�f�#<�
�
�
��
+��{�{�H��
�Wk��FK�s!�FQ�A5Q�DQ�Q�#D-Qr)�__doc__r.�os.pathrryr�rrrrr�
babel.utilr	r
r�textwraprrl�DEFAULT_KEYWORDS�DEFAULT_MAPPINGr|r+r3rMr>rQr\rorprqr4r(r&�<module>r�s����$
��
�?�?�D�D�� �
�
�������
��!���'�'��L��
	(�B�
���
��
���j�^=A�6�r2B�#%�t��:�8'7�R��U�A2�H�s�lDr(

Zerion Mini Shell 1.0