403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/babel/messages/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/babel/messages/__pycache__/pofile.cpython-39.pyc
a

�4d3W�
@sbdZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZer�dd	lmZmZdd
lmZddlmZddd
�dd�Zddd
�dd�ZGdd�de�ZGdd�d�ZGdd�d�Zd6dddddddd�dd �Ze�d!�Zddd
�d"d#�Z d7ddd&dd'�d(d)�Z!d8d+dd&dddddddd,d-�d.d/�Z"d0d1d2d3�d4d5�Z#dS)9z�
    babel.messages.pofile
    ~~~~~~~~~~~~~~~~~~~~~

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

    :copyright: (c) 2013-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�annotationsN)�Iterable)�
TYPE_CHECKING)�Locale)�Catalog�Message)�_cmp�wraptext)�IO�AnyStr)�
SupportsWrite)�Literal�str)�string�returncCs"dd�}t�d��||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
    cSs2|�d�}|dkrdS|dkr"dS|dkr.dS|S)N��n�
�t�	�r�
)�group)�match�m�r�9/usr/lib/python3.9/site-packages/babel/messages/pofile.py�replace_escapes's
z!unescape.<locals>.replace_escapesz\\([\\trn"])r���)�re�compile�sub)rrrrr�unescapes

r"cCsFd|vr:|��}|�d�r&|dd�}tt|�}d�|�St|�SdS)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�""rN�)�
splitlines�
startswith�mapr"�join)rZ
escaped_lines�linesrrr�denormalize4s


r*cs.eZdZdZdddddd��fdd�Z�ZS)	�PoFileErrorzDException thrown by PoParser when an invalid po file is encountered.rr�int�None)�message�catalog�line�linenorcs,t��|�d|���||_||_||_dS)Nz on )�super�__init__r/r0r1)�selfr.r/r0r1��	__class__rrr3VszPoFileError.__init__)�__name__�
__module__�__qualname__�__doc__r3�
__classcell__rrr5rr+Ssr+c@s�eZdZddd�dd�Zddd�dd�Zdd	�d
d�Zdd	�d
d�Zdd	�dd�Zddd�dd�Zddd�dd�Z	ddd�dd�Z
ddd�dd�Zddd�dd�Zddd�dd�Z
ddd�d d!�Zd"S)#�_NormalizedStringrr-)�argsrcGsg|_|D]}|�|�q
dS�N)�_strs�append)r4r=�argrrrr3_sz_NormalizedString.__init__)�srcCs|j�|���dSr>)r?r@�strip)r4rBrrrr@dsz_NormalizedString.append�rcCsd�tt|j��S)Nr$)r(r'r"r?�r4rrrr*gsz_NormalizedString.denormalize�boolcCs
t|j�Sr>)rFr?rErrr�__bool__jsz_NormalizedString.__bool__cCstj�|j�Sr>)�os�linesepr(r?rErrr�__repr__msz_NormalizedString.__repr__�objectr,)�otherrcCs|sdStt|�t|��S)Nr)rr�r4rLrrr�__cmp__psz_NormalizedString.__cmp__cCs|�|�dkS�Nr�rNrMrrr�__gt__vsz_NormalizedString.__gt__cCs|�|�dkSrOrPrMrrr�__lt__ysz_NormalizedString.__lt__cCs|�|�dkSrOrPrMrrr�__ge__|sz_NormalizedString.__ge__cCs|�|�dkSrOrPrMrrr�__le__sz_NormalizedString.__le__cCs|�|�dkSrOrPrMrrr�__eq__�sz_NormalizedString.__eq__cCs|�|�dkSrOrPrMrrr�__ne__�sz_NormalizedString.__ne__N)r7r8r9r3r@r*rGrJrNrQrRrSrTrUrVrrrrr<]sr<c@s�eZdZdZgd�Zd ddddd�dd	�Zdd
�dd�Zdd
�d
d�Zdd
�dd�Zd!dd
�dd�Z	d"dd
�dd�Z
dd
�dd�Zdd
�dd�Zddd�dd�Z
dd
�dd�ZdS)#�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_pluralFrrFr-)r/�ignore_obsolete�
abort_invalidrcCs*||_||_d|_d|_||_|��dSrO)r/r\�counter�offsetr]�_reset_message_state)r4r/r\r]rrrr3�szPoFileParser.__init__rDcCsFg|_g|_g|_g|_g|_g|_d|_d|_d|_d|_	d|_
dS)NF)�messages�translations�	locations�flags�
user_comments�
auto_comments�context�obsolete�in_msgid�	in_msgstr�
in_msgctxtrErrrr`�sz!PoFileParser._reset_message_statec
Cs:|j��t|j�dkr.tdd�|jD��}n|jd��}t|ttf�r�dd�t|j	j
�D�}|jD]2\}}||j	j
kr�|�d|jd�qf|��||<qft|�}n|jdd��}|j
r�|j
��nd	}t||t|j�t|j�|j|j|jd|d
�}|j�r|j�s ||j	j|<n
||j	|<|jd7_|��d	S)z�
        Add a message to the catalog based on the current parser state and
        clear the state ready to process the next message.
        rcss|]}|��VqdSr>)r*)�.0rrrr�	<genexpr>��z,PoFileParser._add_message.<locals>.<genexpr>rcSsg|]}d�qS)r$r)rl�_rrr�
<listcomp>�rnz-PoFileParser._add_message.<locals>.<listcomp>r$z5msg has more translations than num_plurals of catalogN)r1rg)rb�sort�lenra�tupler*�
isinstance�list�ranger/�num_plurals�_invalid_pofiler_rgrrc�setrdrfrerhr\r^r`)r4rXr�idx�translationrZr.rrr�_add_message�s0

�
zPoFileParser._add_messagecCs|jr|��dSr>)rar|rErrr�_finish_current_message�sz$PoFileParser._finish_current_messagecCs*|�d�r|�||�n|�|||�dS)N�")r&�!_process_string_continuation_line�_process_keyword_line)r4r1r0rhrrr�_process_message_line�s
z"PoFileParser._process_message_linec	CsF|jD]Z}z4|�|�r<|t|�dvr<|t|�d�}WqtWqty^|�||d�Yq0q|�||d�dS|dvr�|��||_|dkr�||_|dvr�d|_d|_	|j
�t|��n�|d	k�r(d|_	d|_
|�d
��r|dd��dd�\}}|j�t|�t|�g�n|j�d
t|�g�n|dk�rBd|_t|�|_dS)N)� �[z$Keyword must be followed by a stringz0Start of line didn't match any expected keyword.)rXrZrX)rXr[FTrYr�r�]rrZ)�	_keywordsr&rr�
IndexErrorrxr}rhr_rkrirar@r<rj�splitrbr,rg)r4r1r0rh�keywordrArz�msgrrrr��s8



z"PoFileParser._process_keyword_linecCsV|jr|jd}n6|jr(|jdd}n |jr6|j}n|�||d�dS|�|�dS)Nrrz<Got line starting with " but not in msgid, msgstr or msgctxt)rirarjrbrkrgrxr@)r4r0r1rBrrrr�sz.PoFileParser._process_string_continuation_linec	Cs6|��|dd��d�r�|dd�����D]p}|�d�}|dkr�zt||dd��}WntyrYq.Yn0|j�|d|�|f�q.|j�|df�q.n�|dd��d�r�|dd����d�D]}|j	�|�
��q�nP|dd��d��r|dd��
�}|�r2|j�|�n|j�|dd��
��dS)Nr�:�r�,�.)
r}r&�lstripr��rfindr,�
ValueErrorrcr@rdrCrfre)r4r0�location�posr1�flag�commentrrr�_process_comments&

zPoFileParser._process_comment�
IO[AnyStr])�fileobjrcCs�t|�D]�\}}|��}t|t�s0|�|jj�}|s6q|�d�r||dd��d�rp|j||dd��	�dd�q�|�
|�q|�||�q|��|js�|j
s�|js�|jr�|j�td��|j�d	td�g�|��dS)
z�
        Reads from the file-like object `fileobj` and adds any po file
        units found in it to the `Catalog` supplied to the constructor.
        �#rN�~r�T)rhr#r)�	enumeraterCrtr�decoder/�charsetr&r�r�r�r}r^rdrerfrar@r<rbr|)r4r�r1r0rrr�parse&s 

zPoFileParser.parsecCsJt|t�sJ�|jr$t||j||��td|�td|d�d|���dS)NzWARNING:zWARNING: Problem on line rz: )rtrr]r+r/�print)r4r0r1r�rrrrxCs

zPoFileParser._invalid_pofileN)FF)F)F)r7r8r9r:r�r3r`r|r}r�r�rr�r�rxrrrrrW�s
 )rWFr�zstr | Locale | Nonez
str | NonerFr)r��locale�domainr\r�r]rcCs*t|||d�}t|||d�}|�|�|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
    )r�r�r�)r])rrWr�)r�r�r�r\r�r]r/�parserrrr�read_poKs6
r�zL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))cCs0d|�dd��dd��dd��dd	��d
d�S)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\\rz\trz\rrz\nr~z\")�replace)rrrr�escape�s����r�r$�Lr,)r�prefix�widthrc
s0|r�|dkr�t��}g}|�d�D]�}tt|��||kr�t�|�}|��|r�g}d}|r�tt|d��d|}	||	|kr�|�|���||	7}qX|s�|�|���q�qX|�d�|��qLq"|�|�q"n
|�d�}t|�dkr�t|�S|�r|d�s|d=|dd7<dd��fd	d
�|D��S)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�rr$rrz""
csg|]}�t|��qSr)r�)rlr0�r�rrrp�rnznormalize.<locals>.<listcomp>)	rrr%r��WORD_SEPr��reverser@�popr()
rr�r�Z	prefixlenr)r0�chunks�buf�size�lengthrr�r�	normalize�s6


r�TzSupportsWrite[bytes]r-)r�r/r��no_location�omit_header�sort_output�sort_by_filer\�include_previous�include_linenorc
	sfd"�fdd�	���fdd��d#��fdd�	}
d$���fdd	�	}d
}|rLd}n|rTd}t�|d
�D�]�}
|
js�|rrq`�j}�r��dkr�g}|��D]}|t|�dd�7}q�d�|�}�|�d��|
jD]}|
|�q�|
jD]}|
|dd�q�|�s�g}zt|
j	dd�d�}Wnt
�y&|
j	}Yn0|D]H\}}|�tj
d�}|�r^|	�r^|�d|d��}||v�r,|�|��q,|
d�|�dd�|
j�r��dd�dgt|
j����d��|
j�r|�r|
d�|
jd���dd�t|
j�dk�r|
d �|
jd�dd�||
��d�q`|�sbt�j��|d
�D]0}
|
jD]}|
|��q:||
d!d��d��q0d
S)%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
    r$cst||�d�S)N)r�r�)r�)�keyr�)r�rr�
_normalizeszwrite_po.<locals>._normalizecs&t|t�r|��jd�}��|�dS)N�backslashreplace)rtr�encoder��write)�text)r/r�rr�_writes
zwrite_po.<locals>._writecsB�r�dkr�nd}t||�D]}�d|�d|���d��qdS)Nrr�r�r�r)r	rC)r�r��_widthr0)r�r�rr�_write_commentsz write_po.<locals>._write_commentc	s0t|jttf�r�|jr2�|�d�|j|��d���|�d�|jd|��d���|�d�|jd|��d��t�j�D]L}z|j|}Wnty�d}Yn0�|�d|d	�d
�||��d��q|n`|jr�|�d�|j|��d���|�d�|j|��d���|�d�|j�pd|��d��dS)Nzmsgctxt r�msgid rz
msgid_plural rr$zmsgstr[�dz] zmsgstr )	rt�idrursrgrvrwrr�)r.r�rzr)r�r�r/rr�_write_message#s  
&z write_po.<locals>._write_messageNr.r�)�sort_byrz# )r��subsequent_indentrr�r�cSs"|dt|dt�r|dpdfS)Nrrr)rtr,)�xrrr�<lambda>Wrnzwrite_po.<locals>.<lambda>�r��/r�r�r�r�z, r��|rzmsgid_plural %sz#~ )r$)r$)r$)�_sort_messagesr�Zheader_commentr%r	r(rerf�sortedrc�	TypeErrorr�rH�sepr@rdZprevious_idrrrh�values)r�r/r�r�r�r�r�r\r�r�r�r�r�r.Zcomment_headerr)r0r�Zlocsrc�filenamer1r�r)r�r�r/r�r�r�write_po�s�7�




�

"���
�

r�zIterable[Message]zLiteral['message', 'location']z
list[Message])rar�rcCs6t|�}|dkr|��n|dkr2|jdd�d�|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�cSs|jSr>)rc)rrrrr��rnz _sort_messages.<locals>.<lambda>r�)rurq)rar�rrrr�}s

r�)NNFNF)r$r�)r�FFFFFFT)$r:Z
__future__rrHr�collections.abcr�typingrZ
babel.corerZbabel.messages.catalogrrZ
babel.utilrr	r
rZ	_typeshedrZtyping_extensionsr
r"r*�	Exceptionr+r<rWr�r r�r�r�r�r�rrrr�<module>sL

,E�<
@�$!

Youez - 2016 - github.com/yon3zu
LinuXploit