%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__/pofile.cpython-312.pyc

�

ƪb�U����dZddlZddlZddlmZmZddlmZmZd�Z	d�Z
Gd�de�ZGd	�d
�Z
Gd�d�Zdd
�Zej d�Zd�Zdd�Z			dd�Zd�Zy)z�
    babel.messages.pofile
    ~~~~~~~~~~~~~~~~~~~~~

    Reading and writing of files in the ``gettext`` PO (portable object)
    format.

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�Catalog�Message)�wraptext�_cmpc�X�d�}tjd�j||dd�S)z�Reverse `escape` the given string.

    >>> print(unescape('"Say:\\n  \\"hello, world!\\"\\n"'))
    Say:
      "hello, world!"
    <BLANKLINE>

    :param string: the string to unescape
    c�L�|jd�}|dk(ry|dk(ry|dk(ry|S)N��n�
�t�	�r�
)�group)�match�ms  �7/usr/lib/python3/dist-packages/babel/messages/pofile.py�replace_escapesz!unescape.<locals>.replace_escapess2���K�K��N����8��
�#�X��
�#�X����z\\([\\trn"])r	���)�re�compile�sub)�stringrs  r�unescapers+��	��:�:�o�&�*�*�?�F�1�R�L�I�Irc��d|vrG|j�}|jd�r|dd}tt|�}dj	|�St|�S)a�Reverse the normalization done by the `normalize` function.

    >>> print(denormalize(r'''""
    ... "Say:\n"
    ... "  \"hello, world!\"\n"'''))
    Say:
      "hello, world!"
    <BLANKLINE>

    >>> print(denormalize(r'''""
    ... "Say:\n"
    ... "  \"Lorem ipsum dolor sit "
    ... "amet, consectetur adipisicing"
    ... " elit, \"\n"'''))
    Say:
      "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
    <BLANKLINE>

    :param string: the string to denormalize
    r�""r	N�)�
splitlines�
startswith�mapr�join)r�
escaped_lines�liness   r�denormalizer%*sX��*�v�~��)�)�+�
����T�"�)�!�"�-�M��H�m�,���w�w�u�~�����rc�"��eZdZdZ�fd�Z�xZS)�PoFileErrorzDException thrown by PoParser when an invalid po file is encountered.c�X��t�|�|�d|���||_||_||_y)Nz on )�super�__init__�catalog�line�lineno)�self�messager+r,r-�	__class__s     �rr*zPoFileError.__init__Ks0���
���G�9�D���1�2������	���r)�__name__�
__module__�__qualname__�__doc__r*�
__classcell__)r0s@rr'r'Is���N��rr'c�X�eZdZd�Zd�Zd�Zd�ZeZd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zy
)�_NormalizedStringc�B�g|_|D]}|j|��y�N)�_strs�append)r.�args�args   rr*z_NormalizedString.__init__Ts$����
��	�C��K�K���	rc�V�|jj|j��yr9)r:r;�strip)r.�ss  rr;z_NormalizedString.appendYs���
�
���!�'�'�)�$rc�T�djtt|j��S)Nr)r"r!rr:�r.s rr%z_NormalizedString.denormalize\s���w�w�s�8�T�Z�Z�0�1�1rc�,�t|j�Sr9)�boolr:rBs r�__nonzero__z_NormalizedString.__nonzero___s���D�J�J��rc�T�tjj|j�Sr9)�os�linesepr"r:rBs r�__repr__z_NormalizedString.__repr__ds���z�z���t�z�z�*�*rc�D�|sytt|�t|��S)Nr	)r�str�r.�others  r�__cmp__z_NormalizedString.__cmp__gs�����C��I�s�5�z�*�*rc�*�|j|�dkDS�Nr�rNrLs  r�__gt__z_NormalizedString.__gt__m����|�|�E�"�Q�&�&rc�*�|j|�dkSrPrQrLs  r�__lt__z_NormalizedString.__lt__prSrc�*�|j|�dk\SrPrQrLs  r�__ge__z_NormalizedString.__ge__s����|�|�E�"�a�'�'rc�*�|j|�dkSrPrQrLs  r�__le__z_NormalizedString.__le__vrXrc�*�|j|�dk(SrPrQrLs  r�__eq__z_NormalizedString.__eq__yrXrc�*�|j|�dk7SrPrQrLs  r�__ne__z_NormalizedString.__ne__|rXrN)r1r2r3r*r;r%rE�__bool__rIrNrRrUrWrZr\r^�rrr7r7RsE���
%�2� ��H�+�+�'�'�(�(�(�(rr7c�Z�eZdZdZgd�Zdd�Zd�Zd�Zd�Zdd�Z	dd�Z
d	�Zd
�Zd�Z
d�Zy
)�PoFileParserz�Support class to  read messages from a ``gettext`` PO (portable object) file
    and add them to a `Catalog`

    See `read_po` for simple cases.
    )�msgid�msgstr�msgctxt�msgid_pluralc�j�||_||_d|_d|_||_|j�yrP)r+�ignore_obsolete�counter�offset�
abort_invalid�_reset_message_state)r.r+rhrks    rr*zPoFileParser.__init__�s3�����.���������*����!�!�#rc��g|_g|_g|_g|_g|_g|_d|_d|_d|_d|_	d|_
y)NF)�messages�translations�	locations�flags�
user_comments�
auto_comments�context�obsolete�in_msgid�	in_msgstr�
in_msgctxtrBs rrlz!PoFileParser._reset_message_state�sR����
���������
������������
���
������rc
�P�|jj�t|j�dkDrt	d�|jD��}n|jdj�}t
|ttf�r�t|jj�D�cgc]}d��}}|jD]O\}}||jjk\r|jd|jd��=|j�||<�Qt	|�}n |jddj�}|jr|jj�}nd}t||t|j�t!|j"�|j$|j&|jdz|��}|j(r&|j*s)||jj(|<n||j|<|xj,dz
c_|j/�ycc}w)z�
        Add a message to the catalog based on the current parser state and
        clear the state ready to process the next message.
        r	c3�<K�|]}|j����y�wr9)r%)�.0rs  r�	<genexpr>z,PoFileParser._add_message.<locals>.<genexpr>�s����A�a�!�-�-�/�A�s�rrz5msg has more translations than num_plurals of catalogN)r-rt)ro�sort�lenrn�tupler%�
isinstance�list�ranger+�num_plurals�_invalid_pofilerjrtrrp�setrqrsrrrurhrirl)r.rc�_r�idx�translationrer/s        r�_add_messagezPoFileParser._add_message�s���
	
����� ��t�}�}���!��A�4�=�=�A�A�E��M�M�!�$�0�0�2�E��e�d�E�]�+�"'����(@�(@�"A�B�Q�b�B�F�B�$(�$5�$5�
8� ��[��$�,�,�2�2�2��(�(��d�k�k�;r�s��)�5�5�7��s��	
8�
�6�]�F��&�&�q�)�!�,�8�8�:�F��<�<��l�l�.�.�0�G��G��%���d�n�n�)=�s�4�:�:���,�,�d�.@�.@����WX��")�+���=�=��'�'�/6����%�%�e�,�")�D�L�L����������!�!�#��-Cs�$	H#c�>�|jr|j�yyr9)rnr�rBs r�_finish_current_messagez$PoFileParser._finish_current_message�s���=�=�����rc�r�|jd�r|j||�y|j|||�y)N�")r �!_process_string_continuation_line�_process_keyword_line)r.r-r,rus    r�_process_message_linez"PoFileParser._process_message_line�s0���?�?�3���2�2�4��@��&�&�v�t�X�>rc��|jD]4}	|j|�r |t|�dvr|t|�d}n�6|j	||d�y|dvr|j�||_|dk(r||_|dvr3d|_d|_	|jjt|��y|d	k(r�d|_	d|_
|jd
�rH|ddjdd�\}}|jjt!|�t|�g�y|jjd
t|�g�y|dk(rd|_t|�|_yy#t$r|j	||d�Y��ywxYw)N)� �[z$Keyword must be followed by a stringz0Start of line didn't match any expected keyword.)rcrerc)rcrfFTrdr�r	�]rre)�	_keywordsr r~�
IndexErrorr�r�rurjrxrvrnr;r7rw�splitro�intrt)r.r-r,ru�keywordr=r��msgs        rr�z"PoFileParser._process_keyword_line�s����~�~�		�G�
[��?�?�7�+��S��\�0B�j�0P��s�7�|�}�-�C���			�
� � ��v�/a�b���*�*��(�(�*� ��
��g�� �D�K��/�/�#�D�O� �D�M��M�M� � �!2�3�!7�8�
��
 �!�D�M�!�D�N��~�~�c�"��q�r�7�=�=��a�0���S��!�!�(�(�#�c�(�4E�c�4J�)K�L��!�!�(�(�!�->�s�-C�)D�E�
�	�
!�"�D�O�,�S�1�D�L�"��=�
[��$�$�T�6�3Y�Z�
[�s�/E'�'F�Fc��|jr|jd}nL|jr|jdd}n-|jr
|j
}n|j
||d�y|j|�y)Nrr	z<Got line starting with " but not in msgid, msgstr or msgctxt)rvrnrwrorxrtr�r;)r.r,r-r@s    rr�z.PoFileParser._process_string_continuation_line�sd���=�=��
�
�b�!�A�
�^�^��!�!�"�%�a�(�A�
�_�_����A�� � ��v�/n�o��	����rc�4�|j�|ddjd�r�|ddj�j�D]h}|j	d�}|dk\r3	t||dzd�}|jj|d||f��L|jj|df��jy|ddjd�rQ|ddj�jd�D]+}|jj|j���-y|ddjd�r2|ddj�}|r|jj|�yy|jj|ddj��y#t$rY��PwxYw)Nr	�:�r�,�.)
r�r �lstripr��rfindr��
ValueErrorrpr;rqr?rsrr)r.r,�location�posr-�flag�comments       r�_process_commentzPoFileParser._process_commentsz���$�$�&����8���s�#� ���H�O�O�-�3�3�5�	
<���n�n�S�)���!�8�!�!$�X�c�A�g�h�%7�!8���N�N�)�)�8�D�S�>�6�*B�C��N�N�)�)�8�T�*:�;�	
<��!�"�X�
 �
 ��
%��Q�R����)�/�/��4�
0���
�
�!�!�$�*�*�,�/�
0�
�!�"�X�
 �
 ��
%��1�2�h�n�n�&�G���"�"�)�)�'�2��
���%�%�d�1�2�h�n�n�&6�7��&�!� �!�s� F
�
	F�Fc���t|�D]�\}}|j�}t|t�s%|j	|j
j�}|s�N|jd�rL|ddjd�r&|j||ddj�d����|j|���|j||���|j�|js�|js|js|jr[|j j#t%d��|j&j#d	t%d�g�|j)�yyy)
z�
        Reads from the file-like object `fileobj` and adds any po file
        units found in it to the `Catalog` supplied to the constructor.
        �#r	N�~r�T)rurr)�	enumerater?r�rK�decoder+�charsetr r�r�r�r�rirqrrrsrnr;r7ror�)r.�fileobjr-r,s    r�parsezPoFileParser.parse!s)��&�g�.�	9�L�F�D��:�:�<�D��d�C�(��{�{�4�<�<�#7�#7�8�������s�#����8�&�&�s�+��.�.�v�t�A�B�x���7H�SW�.�X��)�)�$�/��*�*�6�4�8�	9�	
�$�$�&��|�|����t�/A�/A�T�EW�EW��M�M� � �!2�5�!9�:����$�$�a�):�5�)A�%B�C�����FX�|rc���t|t�sJ�|jrt||j||��td|�tdj
|dzt|���y)NzWARNING:z!WARNING: Problem on line {0}: {1}r	)r�rKrkr'r+�print�format�repr)r.r,r-r�s    rr�zPoFileParser._invalid_pofile>sZ���$��$�$�$�����c�4�<�<��v�>�>�
�j�#��	�2�9�9�&�1�*�d�4�j�Q�RrN)FF)F)r1r2r3r4r�r*rlr�r�r�r�r�r�r�r�r`rrrbrb�sC����I�$� �!$�F �?�'2�R
�8�6 �:Srrbc�`�t|||��}t|||��}|j|�|S)a�Read messages from a ``gettext`` PO (portable object) file from the given
    file-like object and return a `Catalog`.

    >>> from datetime import datetime
    >>> from io import StringIO
    >>> buf = StringIO('''
    ... #: main.py:1
    ... #, fuzzy, python-format
    ... msgid "foo %(name)s"
    ... msgstr "quux %(name)s"
    ...
    ... # A user comment
    ... #. An auto comment
    ... #: main.py:3
    ... msgid "bar"
    ... msgid_plural "baz"
    ... msgstr[0] "bar"
    ... msgstr[1] "baaz"
    ... ''')
    >>> catalog = read_po(buf)
    >>> catalog.revision_date = datetime(2007, 4, 1)

    >>> for message in catalog:
    ...     if message.id:
    ...         print((message.id, message.string))
    ...         print(' ', (message.locations, sorted(list(message.flags))))
    ...         print(' ', (message.user_comments, message.auto_comments))
    (u'foo %(name)s', u'quux %(name)s')
      ([(u'main.py', 1)], [u'fuzzy', u'python-format'])
      ([], [])
    ((u'bar', u'baz'), (u'bar', u'baaz'))
      ([(u'main.py', 3)], [])
      ([u'A user comment'], [u'An auto comment'])

    .. versionadded:: 1.0
       Added support for explicit charset argument.

    :param fileobj: the file-like object to read the PO file from
    :param locale: the locale identifier or `Locale` object, or `None`
                   if the catalog is not bound to a locale (which basically
                   means it's a template)
    :param domain: the message domain
    :param ignore_obsolete: whether to ignore obsolete messages in the input
    :param charset: the character set of the catalog.
    :param abort_invalid: abort read if po file is invalid
    )�locale�domainr�)rk)rrbr�)r�r�r�rhr�rkr+�parsers        r�read_por�Is2��^�V�F�G�D�G�
�'�?�-�
P�F�
�L�L����NrzL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))c��d|jdd�jdd�jdd�jdd	�jd
d�zS)z�Escape the given string so that it can be included in double-quoted
    strings in ``PO`` files.

    >>> escape('''Say:
    ...   "hello, world!"
    ... ''')
    '"Say:\\n  \\"hello, world!\\"\\n"'

    :param string: the string to escape
    z"%s"�\z\\r
z\trz\rrz\nr�z\")�replace)rs r�escaper��sN���F�N�N�4��0�"�7�4��/�"�7�4��/�"�7�4��/�"�7�4��/�	0�0rc
��|�r|dkD�rt|�}g}|jd�D]�}tt|��|z|kDr�tj	|�}|j�|s�Eg}d}|rott|d��dz
|z}	||	z|kr%|j
|j��||	z
}n"|s|j
|j��n|r�o|j
dj|��|r����|j
|���n|jd�}t|�dkrt|�S|r|ds|d=|dxxdz
cc<ddj|D�cgc]}|t|�z��c}�zScc}w)	a�Convert a string into a format that is appropriate for .po files.

    >>> print(normalize('''Say:
    ...   "hello, world!"
    ... ''', width=None))
    ""
    "Say:\n"
    "  \"hello, world!\"\n"

    >>> print(normalize('''Say:
    ...   "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
    ... ''', width=32))
    ""
    "Say:\n"
    "  \"Lorem ipsum dolor sit "
    "amet, consectetur adipisicing"
    " elit, \"\n"

    :param string: the string to normalize
    :param prefix: a string that should be prepended to every line
    :param width: the maximum line width; use `None`, 0, or a negative number
                  to completely disable line wrapping
    rTr�rrr	rz""
)	r~rr��WORD_SEPr��reverser;�popr")
r�prefix�width�	prefixlenr$r,�chunks�buf�size�ls
          r�	normalizer��sq��0
������K�	����%�%�d�+�	#�D��6�$�<� �9�,�u�4�!����-����� ���C��D� ���v�b�z� 2�3�a�7�)�C���!�8�e�+��J�J�v�z�z�|�4� �A�I�D�#&�!$�
�
�6�:�:�<� 8�!�!��L�L����#��/�� ���T�"�)	#�,�!�!�$�'��
�5�z�Q���f�~��
�U�2�Y��"�I�
�b�	�T��	��U�Z�Z�U� K�T�&�6�$�<�"7� K�L�L�L�� Ks�+F	
c

�J������d�fd�	���fd��d��fd�	}
d���fd�	}d}|rd}n|rd}t�|�	�D�]�}
|
jsZ|r��j}�r>�d
kDr9g}|j�D]}|t	|�d��z
}�d
j|�}�|d
z�|
jD]
}|
|��|
jD]}|
|d���|s�g}	t|
jd���}|D]h\}}|r(|	r&d|jtjd�|fz}n#d|jtjd�z}||vs�X|j|��j|
dj|�d��|
jr1�ddjdgt|
j�z�z�|
j rZ|rX|
d�|
j d
�zd��t#|
j �dkDr |
d�|
j d�zd��||
��d
����|sVt�j$j'�|�	�D]-}
|
jD]
}|
|��||
d���d
��/yy#t$r|
j}Y���wxYw)a�Write a ``gettext`` PO (portable object) template file for a given
    message catalog to the provided file-like object.

    >>> catalog = Catalog()
    >>> catalog.add(u'foo %(name)s', locations=[('main.py', 1)],
    ...             flags=('fuzzy',))
    <Message...>
    >>> catalog.add((u'bar', u'baz'), locations=[('main.py', 3)])
    <Message...>
    >>> from io import BytesIO
    >>> buf = BytesIO()
    >>> write_po(buf, catalog, omit_header=True)
    >>> print(buf.getvalue().decode("utf8"))
    #: main.py:1
    #, fuzzy, python-format
    msgid "foo %(name)s"
    msgstr ""
    <BLANKLINE>
    #: main.py:3
    msgid "bar"
    msgid_plural "baz"
    msgstr[0] ""
    msgstr[1] ""
    <BLANKLINE>
    <BLANKLINE>

    :param fileobj: the file-like object to write to
    :param catalog: the `Catalog` instance
    :param width: the maximum line width for the generated output; use `None`,
                  0, or a negative number to completely disable line wrapping
    :param no_location: do not emit a location comment for every message
    :param omit_header: do not include the ``msgid ""`` entry at the top of the
                        output
    :param sort_output: whether to sort the messages in the output by msgid
    :param sort_by_file: whether to sort the messages in the output by their
                         locations
    :param ignore_obsolete: whether to ignore obsolete messages and not include
                            them in the output; by default they are included as
                            comments
    :param include_previous: include the old msgid as a comment when
                             updating the catalog
    :param include_lineno: include line number in the location comment
    rc� ��t||���S)N)r�r�)r�)�keyr�r�s  �r�
_normalizezwrite_po.<locals>._normalizes�����V�5�9�9rc���t|t�r|j�jd�}�j	|�y)N�backslashreplace)r�rK�encoder��write)�textr+r�s ��r�_writezwrite_po.<locals>._writes.����d�C� ��;�;�w���0B�C�D��
�
�d�rc�z���r�dkDr�}nd}t||�D]}�d|�d|j��d���!y)Nr�Lr�r�r)rr?)r�r��_widthr,r�r�s    ��r�_write_commentz write_po.<locals>._write_comment
sA����U�Q�Y��F��F��W�f�-�	8�D�������6�7�	8rc
���t|jttf�r�|jr�|�d�|j|��d���|�d�|jd|��d���|�d�|jd|��d��t�j�D]'}	|j|}�d||�||�fz��)y|jr�|�d�|j|��d���|�d�|j|��d���|�d	�|jxsd|��d��y#t$rd}Y��wxYw)
Nzmsgctxt rzmsgid rz
msgid_plural r	rz%smsgstr[%d] %s
zmsgstr )	r��idr�rrtr�r�rr�)r/r�r�rr�r�r+s    ���r�_write_messagez write_po.<locals>._write_messagesD����g�j�j�4��-�0�����6�+5�g�o�o�v�+N�P�Q��V�Z��
�
�1�
�v�-N�O�P���
�7�:�:�a�=�&�9��
��W�0�0�1�
�� �$�^�^�C�0�F��*��C��F�F�!;�.���
�����6�+5�g�o�o�v�+N�P�Q��V�Z��
�
�F�-K�L�M���
�7�>�>�#7�R��@��
��"� ��F� �s�*D?�?E
�E
Nr/r�)�sort_byrz# )r��subsequent_indentrr�)r�c�H�|dt|dt�xr|dxsdfS)Nrr	r)r�r�)�xs r�<lambda>zwrite_po.<locals>.<lambda>Ps,��!�A�$�
�1�Q�4��8M�8V�RS�TU�RV�8\�Z\�1]�r�r�z%s:%d�/z%sr�r�z#%s
z, zmsgid %s�|r	zmsgid_plural %sz#~ )r)�_sort_messagesr��header_commentrrr"rrrs�sortedrp�	TypeErrorr�rG�sepr;rq�previous_idr~ru�values)r�r+r��no_location�omit_header�sort_output�sort_by_filerh�include_previous�include_linenor�r�r�r/�comment_headerr$r,r��locsrp�filenamer-r�r�r�s```                    @@r�write_por��s����\:��
8��6�G����	���!�'�7�;�3���z�z���$�3�3�N�������*�5�5�7�>�D��X�d�%�8<�>�>�E�>�"'���E�!2���>�E�)�*��,�,�	$�G��7�#�	$��,�,�	0�G��7�3�/�	0���D�
.�"�7�#4�#4�']�_�	�
%.�
*� ��&��n�'�8�+;�+;�B�F�F�C�+H�&�*Q�Q�H�$�x�'7�'7�����'D�D�H��4�'��K�K��)�

*�
�3�8�8�D�>�#�6��=�=��7�T�Y�Y��t�f�W�]�]�.C�'C�D�D�E����#3��:�
�7�3F�3F�q�3I�(J�J�"%�
'��7�&�&�'�!�+��0�:��'�'��*�4� ���	�w���t��g3�j�%����#�#�%��
�	�G�#�0�0�
(���w�'�
(��7�5�1��4�L�	���3�
.�#�-�-�	�
.�s�J	�	J"�!J"c�z�t|�}|dk(r|j�|S|dk(r|jd���|S)z�
    Sort the given message iterable by the given criteria.

    Always returns a list.

    :param messages: An iterable of Messages.
    :param sort_by: Sort by which criteria? Options are `message` and `location`.
    :return: list[Message]
    r/r�c��|jSr9)rp)rs rr�z _sort_messages.<locals>.<lambda>�s
��A�K�K�rr�)r�r})rnr�s  rr�r�usC���H�~�H��)���
�
���O�
�J�	��
�
�/�
�0��Or)NNFNF)rr�)r�FFFFFFT)r4rGr�babel.messages.catalogrr�
babel.utilrrrr%�	Exceptionr'r7rbr�rr�r�r�r�r�r`rr�<module>r�s���	�
�	�3�%�J�. �>�)��+(�+(�^ES�ES�P2�j�2�:�:����0�$:M�zIN�DI�48�^�Br

Zerion Mini Shell 1.0