403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.117.196.112
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3.6/site-packages/babel/messages/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/babel/messages/__pycache__/pofile.cpython-36.opt-1.pyc
3

H��X�M�@s�dZddlmZddlZddlZddlmZmZddlm	Z	ddl
mZdd�Zd	d
�Z
Gdd�de�ZGd
d�de�Zddd�Zejd�Zdd�Zddd�Zd dd�Zdd�ZdS)!z�
    babel.messages.pofile
    ~~~~~~~~~~~~~~~~~~~~~

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

    :copyright: (c) 2013 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�print_functionN)�Catalog�Message)�wraptext)�	text_typecCs"dd�}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
    cSs2|jd�}|dkrdS|dkr"dS|dkr.dS|S)N��n�
�t�	�r�
)�group)�match�m�r�/usr/lib/python3.6/pofile.py�replace_escapes s
z!unescape.<locals>.replace_escapesz\\([\\trn"])r���)�re�compile�sub)�stringrrrr�unescapes

rcCsFd|kr:|j�}|jd�r&|dd�}tt|�}dj|�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	z""rN�)�
splitlines�
startswith�mapr�join)rZ
escaped_lines�linesrrr�denormalize-s


r c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�_NormalizedStringcGs"g|_x|D]}|j|�qWdS)N)�_strs�append)�self�args�argrrr�__init__Ns
z_NormalizedString.__init__cCs|jj|j��dS)N)r"r#�strip)r$�srrrr#Ssz_NormalizedString.appendcCsdjtt|j��S)Nr)rrrr")r$rrrr Vsz_NormalizedString.denormalizecCs
t|j�S)N)�boolr")r$rrr�__nonzero__Ysz_NormalizedString.__nonzero__N)�__name__�
__module__�__qualname__r'r#r r+rrrrr!Lsr!c@sreZdZdZddddgZddd�Zd	d
�Zdd�Zd
d�Zddd�Z	ddd�Z
dd�Zdd�Zdd�Z
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_pluralFcCs$||_||_d|_d|_|j�dS)Nr)�catalog�ignore_obsolete�counter�offset�_reset_message_state)r$r4r5rrrr'ks
zPoFileParser.__init__cCsFg|_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_msgctxt)r$rrrr8rsz!PoFileParser._reset_message_statec
Cs@|jj�t|j�dkr.tdd�|jD��}n|jdj�}t|ttf�r�dd�t|j	j
�D�}x<|jD]2\}}||j	j
kr�|jd|jd�qh|j�||<qhWt|�}n|jddj�}|j
r�|j
j�}nd}t||t|j�t|j�|j|j|jd|d	�}|j�r|j�s&||j	j|<n
||j	|<|jd7_|j�dS)
z�
        Add a message to the catalog based on the current parser state and
        clear the state ready to process the next message.
        rcSsg|]}|j��qSr)r )�.0rrrr�
<listcomp>�sz-PoFileParser._add_message.<locals>.<listcomp>rcSsg|]}d�qS)rr)rD�_rrrrE�srz5msg has more translations than num_plurals of catalogN)�linenor?)r:�sort�lenr9�tupler �
isinstance�list�ranger4�num_plurals�_invalid_pofiler7r?rr;�setr<r>r=r@r5r6r8)r$r0r�idxZtranslationr2�messagerrr�_add_messages2


zPoFileParser._add_messagecCs|jr|j�dS)N)r9rS)r$rrr�_finish_current_message�sz$PoFileParser._finish_current_messagecCs*|jd�r|j||�n|j|||�dS)N�")r�!_process_string_continuation_line�_process_keyword_line)r$rG�liner@rrr�_process_message_line�s
z"PoFileParser._process_message_linecCsxL|jD]0}|j|�r|t|�d
kr|t|�d�}PqW|j||d�dS|dkr^|j�||_|dkrr||_|dkr�d|_d|_|j	j
t|��n�|d	k�rd|_d|_|jd�r�|d
d�j
dd
�\}}|jj
t|�t|�g�n|jj
dt|�g�n|dk�rd|_t|�|_dS)N� �[z0Start of line didn't match any expected keyword.r0r2r3FTr1r�]r)rZr[)r0r2)r0r3)�	_keywordsrrIrOrTr@r7rCrAr9r#r!rB�splitr:�intr?)r$rGrXr@�keywordr&rQ�msgrrrrW�s2


z"PoFileParser._process_keyword_linecCsV|jr|jd}n6|jr(|jdd}n |jr6|j}n|j||d�dS|j|�dS)Nrz<Got line starting with " but not in msgid, msgstr or msgctxtrr)rAr9rBr:rCr?rOr#)r$rXrGr)rrrrV�sz.PoFileParser._process_string_continuation_linec
Cs>|j�|dd�jd�r�x�|dd�j�j�D]p}|jd�}|dkr�yt||dd��}Wntk
rtw0YnX|jj|d|�|f�q0|jj|df�q0Wn�|dd�jd�r�x�|dd�j�jd�D]}|j	j|j
��q�WnP|dd�jd��r"|dd�j
�}|�r:|jj|�n|jj|dd�j
��dS)Nr�:�r�,�.)
rTr�lstripr^�rfindr_�
ValueErrorr;r#r<r(r>r=)r$rX�location�posrG�flag�commentrrr�_process_comment�s&
zPoFileParser._process_commentcCs�x�t|�D]�\}}|j�}t|t�s2|j|jj�}|s8q
|jd�r~|dd�jd�rr|j||dd�j	�dd�q�|j
|�q
|j||�q
W|j�|jr�|j
s�|js�|jr�|jjtd��|jjd	td�g�|j�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�~rcT)r@z""r)�	enumerater(rKr�decoder4�charsetrrYrfrmrTr6r<r=r>r9r#r!r:rS)r$�fileobjrGrXrrr�parse�s 

zPoFileParser.parsecCs"td|�tdj|d|��dS)NzWARNING:z!WARNING: Problem on line {0}: {1}r)�print�format)r$rXrGrarrrrOs
zPoFileParser._invalid_pofileN)F)F)F)r,r-r.�__doc__r]r'r8rSrTrYrWrVrmrtrOrrrrr/]s

#

&r/FcCs&t|||d�}t||�}|j|�|S)aTRead messages from a ``gettext`` PO (portable object) file from the given
    file-like object and return a `Catalog`.

    >>> from datetime import datetime
    >>> from babel._compat 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.
    )�locale�domainrr)rr/rt)rsrxryr5rrr4�parserrrr�read_pos.

r{zL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))cCs0d|jdd�jdd�jdd�jdd	�jd
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\tr
z\rr	z\nrUz\")�replace)rrrr�escapeVs
r~r�Lc
s>|r�|dkr�t��}g}x�|jd�D]�}tt|��||kr�tj|�}|j�x�|r�g}d}xX|r�tt|d
��d|}	||	|kr�|j|j��||	7}q^|s�|j|j��Pq^W|jdj|��qPWq$|j|�q$Wn
|jd�}t|�dkr�t|�S|�r"|d�r"|d=|d
d7<ddj�fdd	�|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
    rTrcrrr	z""
csg|]}�t|��qSr)r~)rDrX)�prefixrrrE�sznormalize.<locals>.<listcomp>rrrr)	rIrr~�WORD_SEPr^�reverser#�popr)
rr��widthZ	prefixlenrrXZchunksZbuf�size�lr)r�r�	normalizehs6


r�Tc
sTd �fdd�	���fdd��d!��fdd�	}
d"���fdd	�	}d
}|rLd}n|rTd}�x�t�|d
�D�]�}
|
js�|rvqd�j}�r��dkr�g}x"|j�D]}|t|�dd�7}q�Wdj|�}�|d�x|
jD]}|
|�q�Wx|
jD]}|
|dd�q�W|�srg}xZt|
j	�D]L\}}|�rB|	�rB|j
d|jtj
d�|f�n|j
d|jtj
d���qW|
dj|�dd�|
j�r��ddjdgt|
j���|
j�r�|�r�|
d�|
jd�dd�t|
j�dk�r�|
d�|
jd�dd�||
��d�qdW|�sPxJt�jj�|d
�D]4}
x|
jD]}|
|��q$W||
dd��d��qWd
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 babel._compat 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
    rcst||�d�S)N)r�r�)r�)�keyr�)r�rr�
_normalize�szwrite_po.<locals>._normalizecs&t|t�r|j�jd�}�j|�dS)N�backslashreplace)rKr�encoderr�write)�text)r4rsrr�_write�s
zwrite_po.<locals>._writecsB�r�dkr�}nd}x&t||�D]}�d||j�f�q"WdS)Nrrz#%s %s
)rr()rlr�Z_widthrX)r�r�rr�_write_comment�s
z write_po.<locals>._write_commentcst|jttf�r�|jr.�d|�|j|�f��d|�|jd|�f��d|�|jd|�f�x�t�j�D]D}y|j|}Wntk
r�d}YnX�d||�||�f�qrWnT|jrڈd|�|j|�f��d|�|j|�f��d|�|j�pd|�f�dS)	Nz
%smsgctxt %s
z%smsgid %s
rz%smsgid_plural %s
rrz%smsgstr[%d] %s
z%smsgstr %s
)	rK�idrLrJr?rMrNr�
IndexError)rRr�rQr)r�r�r4rr�_write_message�s(
z write_po.<locals>._write_messageNrRri)�sort_byrz# )r�Zsubsequent_indentr	re)r�z%s:%d�/z%srZrbz#%s
z, zmsgid %s�|rzmsgid_plural %sz#~ )r)r)r)�_sort_messagesr�Zheader_commentrrrr=r>�sortedr;r#r}�os�sepr<Zprevious_idrIr@�values)rsr4r�Zno_locationZomit_headerZsort_outputZsort_by_filer5Zinclude_previousZinclude_linenor�r�r�rRZcomment_headerrrXrlZlocs�filenamerGr)r�r�r4rsr�r�write_po�sf.

r�cCs6t|�}|dkr|j�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]
    rRricSs|jS)N)r;)rrrr�<lambda>Gsz _sort_messages.<locals>.<lambda>)r�)rLrH)r9r�rrrr�9s

r�)NNFN)rr)rFFFFFFT)rwZ
__future__rr�rZbabel.messages.catalogrrZ
babel.utilrZ
babel._compatrrr �objectr!r/r{rr�r~r�r�r�rrrr�<module>s(?
4

=


Youez - 2016 - github.com/yon3zu
LinuXploit