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__/catalog.cpython-39.pyc
a

�4d��@sjUdZddlmZddlZddlZddlmZddlmZm	Z	ddl
m
Z
ddlmZddl
mZdd	lmZdd
lmZddlmZddlmZmZdd
lmZddlmZddlmZmZm Z m!Z!er�ddl"m#Z#e$e%e$dfBe&e$BZ'de(d<gd�Z)d)dd�Z*e�+dej,�Z-ddd�dd�Z.Gdd �d �Z/Gd!d"�d"e0�Z1d#Z2dd$d�d%d&�Z3Gd'd(�d(�Z4dS)*z�
    babel.messages.catalog
    ~~~~~~~~~~~~~~~~~~~~~~

    Data structures for message catalogs.

    :copyright: (c) 2013-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�annotationsN)�OrderedDict)�Iterable�Iterator)�copy)�SequenceMatcher)�message_from_string)�nlargest)�
TYPE_CHECKING)�__version__)�Locale�UnknownLocaleError)�format_datetime)�
get_plural)�LOCALTZ�FixedOffsetTimezone�_cmp�distinct)�	TypeAlias.r�
_MessageID)�Message�Catalog�TranslationError��333333�?cCs�|dkstd|����d|kr*dks:ntd|����g}tdd�}|�|�|D]D}|�|�|��|krV|��|krV|��|krV|�|��|f�qVt||�}dd	�|D�S)
z�A modified version of ``difflib.get_close_matches``.

    It just passes ``autojunk=False`` to the ``SequenceMatcher``, to work
    around https://github.com/python/cpython/issues/90825.
    rzn must be > 0: gg�?zcutoff must be in [0.0, 1.0]: F)ZautojunkcSsg|]\}}|�qS�r)�.0Zscore�xrr�:/usr/lib/python3.9/site-packages/babel/messages/catalog.py�
<listcomp>:�z%get_close_matches.<locals>.<listcomp>)	�
ValueErrorrZset_seq2Zset_seq1Zreal_quick_ratioZquick_ratioZratio�appendr	)ZwordZ
possibilities�n�cutoff�result�srrrr�get_close_matches#s"



�
�
r'z�
    \%
        (?:\(([\w]*)\))?
        (
            [-#0\ +]?(?:\*|[\d]+)?
            (?:\.(?:\*|[\d]+))?
            [hlL]?
        )
        ([diouxXeEfFgGcrs%])
�strzdatetime.datetime)�value�returncCs�t�d|�}tj�|�d�d�}|�d�}|dur�|d|dd�}}|dd�|dd�}}t|�d��}t|�}	t|�}
|	d	}||
7}||9}t|�}|j|d
�}|S)Nz+^(?P<datetime>.*?)(?P<tzoffset>[+-]\d{4})?$�datetimez%Y-%m-%d %H:%M�tzoffsetr���1�<��tzinfo)�re�matchr+�strptime�group�intr�replace)r)r4Zdtr,Zplus_minus_s�restZhours_offset_sZ
mins_offset_sZ
plus_minusZhours_offsetZmins_offsetZnet_mins_offsetrrr�_parse_datetime_headerIs
r:c@seZdZdZd4dddddddd	d
dd�
d
d�Zdd�dd�Zddd�dd�Zddd�dd�Zddd�dd�Zddd�dd�Z	ddd�dd �Z
ddd�d!d"�Zddd�d#d$�Zddd�d%d&�Z
dd�d'd(�Zd5d)d*d+�d,d-�Zedd�d.d/��Zedd�d0d1��Zedd�d2d3��ZdS)6rz0Representation of a single message in a catalog.�rNr�_MessageID | None�Iterable[tuple[str, int]]�
Iterable[str]�
int | None�
str | None�None�
�id�string�	locations�flags�
auto_comments�
user_comments�previous_id�lineno�contextr*c

Cs�||_|s|jrd}||_tt|��|_t|�|_|rJ|jrJ|j�	d�n|j�
d�tt|��|_tt|��|_t
|t�r�|g|_n
t|�|_||_|	|_dS)a_Create the message object.

        :param id: the message ID, or a ``(singular, plural)`` tuple for
                   pluralizable messages
        :param string: the translated message string, or a
                       ``(singular, plural)`` tuple for pluralizable messages
        :param locations: a sequence of ``(filename, lineno)`` tuples
        :param flags: a set or sequence of flags
        :param auto_comments: a sequence of automatic comments for the message
        :param user_comments: a sequence of user comments for the message
        :param previous_id: the previous message ID, or a ``(singular, plural)``
                            tuple for pluralizable messages
        :param lineno: the line number on which the msgid line was found in the
                       PO file, if any
        :param context: the message context
        )r;r;z
python-formatN)rC�pluralizablerD�listrrE�setrF�
python_format�add�discardrGrH�
isinstancer(rIrJrK)
�selfrCrDrErFrGrHrIrJrKrrr�__init__js 





zMessage.__init__r(�r*cCs&dt|�j�d|j�dt|j��d�S)N�<� z	 (flags: z)>)�type�__name__rCrMrF�rSrrr�__repr__�szMessage.__repr__�objectr7��otherr*cCsdd�}t||�||��S)z0Compare Messages, taking into account plural idscSs4t|t�r$|jr$|jd|jp dfS|j|jp0dfS)Nrr;)rRrrLrCrK)�objrrr�values_to_compare�sz*Message.__cmp__.<locals>.values_to_compare)r)rSr^r`rrr�__cmp__�szMessage.__cmp__�boolcCs|�|�dkS�Nr�ra�rSr^rrr�__gt__�szMessage.__gt__cCs|�|�dkSrcrdrerrr�__lt__�szMessage.__lt__cCs|�|�dkSrcrdrerrr�__ge__�szMessage.__ge__cCs|�|�dkSrcrdrerrr�__le__�szMessage.__le__cCs|�|�dkSrcrdrerrr�__eq__�szMessage.__eq__cCs|�|�dkSrcrdrerrr�__ne__�szMessage.__ne__cCst|t�sJ�|j|jkS)z[Checks whether messages are identical, taking into account all
        properties.
        )rRr�__dict__rerrr�is_identical�szMessage.is_identicalcCs2ttt|j|j|j|j|j|j|j	|j
|jf	��S�N)r�maprrCrDrErFrGrHrIrJrKrZrrr�clone�s
�z
Message.clonezCatalog | Nonezlist[TranslationError])�catalogr*cCs\ddlm}g}|D]B}z|||�WqtyT}z|�|�WYd}~qd}~00q|S)a�Run various validation checks on the message.  Some validations
        are only performed if the catalog is provided.  This method returns
        a sequence of `TranslationError` objects.

        :rtype: ``iterator``
        :param catalog: A catalog instance that is passed to the checkers
        :see: `Catalog.check` for a way to perform checks for all messages
              in a catalog.
        r)�checkersN)Zbabel.messages.checkersrrrr")rSrqrr�errorsZchecker�errr�check�s
"z
Message.checkcCs
d|jvS)aWhether the translation is fuzzy.

        >>> Message('foo').fuzzy
        False
        >>> msg = Message('foo', 'foo', flags=['fuzzy'])
        >>> msg.fuzzy
        True
        >>> msg
        <Message 'foo' (flags: ['fuzzy'])>

        :type:  `bool`�fuzzy�rFrZrrrrv�s
z
Message.fuzzycCst|jttf�S)z�Whether the message is plurizable.

        >>> Message('foo').pluralizable
        False
        >>> Message(('foo', 'bar')).pluralizable
        True

        :type:  `bool`)rRrCrM�tuplerZrrrrL�s
zMessage.pluralizablecCs,|j}t|ttf�s|g}tdd�|D��S)z�Whether the message contains Python-style parameters.

        >>> Message('foo %(name)s bar').python_format
        True
        >>> Message(('foo %(name)s', 'foo %(name)s')).python_format
        True

        :type:  `bool`css|]}t�|�VqdSrn)�
PYTHON_FORMAT�search)rrCrrr�	<genexpr>�r z(Message.python_format.<locals>.<genexpr>)rCrRrMrx�any)rSZidsrrrrO�s
zMessage.python_format)r;rrrrrNN)N)rY�
__module__�__qualname__�__doc__rTr[rarfrgrhrirjrkrmrpru�propertyrvrLrOrrrrrgs6�"/rc@seZdZdZdS)rz_Exception thrown by translation checkers when invalid message
    translations are encountered.N)rYr}r~rrrrrrsrz�# Translations template for PROJECT.
# Copyright (C) YEAR ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#zdict[str, str]cCs&ddlm}|�}||d<t|���S)Nr)r�content-type)Z
email.messager�dictZ
get_params)r)r�mrrr�parse_separated_headersr�c@s6eZdZdZddeddddddddddf
dddddddddddddd	d
�dd�Zd
d	d�dd�Zdd�dd�Zdd�dd�Ze	ee�Z
e	e�Zdd�dd�Zdd	d�dd�Z
e	ee
dd�Zdd�d d!�Zdbd$dddd%�d&d'�Zd(d	d)�d*d+�Ze	eed,d�Ze	d-d�d.d/��Ze	dd�d0d1��Ze	dd�d2d3��Zd4dd5�d6d7�Zd-d�d8d9�Zd:d�d;d<�Zdd�d=d>�Zd4d	d5�d?d@�Zd4dAd5�dBdC�Zd4dAd	dD�dEdF�Zdcd4dHdIdJdJdJd4dKddAdL�
dMdN�ZdOd�dPdQ�Zddd4ddRdS�dTdU�Zded4dd	dS�dVdW�Z dfddddd	dY�dZd[�Z!dgd4dd\dS�d]d^�Z"ddd_�d`da�Z#dS)hrz$Representation of a message catalog.NTzstr | Locale | Noner@zdatetime.datetime | str | Nonez6datetime.datetime | datetime.time | float | str | NonerbrA)�locale�domain�header_comment�project�version�copyright_holder�msgid_bugs_address�
creation_date�
revision_date�last_translator�
language_team�charsetrvr*cCs�||_||_||_t�|_|p d|_|p*d|_|p4d|_|p>d|_|
pHd|_	|pRd|_
|p\d|_|durvtj�
t�}nt|tj�r�|js�|jtd	�}||_|	dur�d
}	nt|	tj�r�|	js�|	jtd	�}	|	|_|
|_t�|_d|_d|_dS)aDInitialize the catalog object.

        :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 header_comment: the header comment as string, or `None` for the
                               default header
        :param project: the project's name
        :param version: the project's version
        :param copyright_holder: the copyright holder of the catalog
        :param msgid_bugs_address: the email address or URL to submit bug
                                   reports to
        :param creation_date: the date the catalog was created
        :param revision_date: the date the catalog was revised
        :param last_translator: the name and email of the last translator
        :param language_team: the name and email of the language team
        :param charset: the encoding to use in the output (defaults to utf-8)
        :param fuzzy: the fuzzy bit on the catalog header
        �PROJECT�VERSION�ORGANIZATIONz
EMAIL@ADDRESSzFULL NAME <EMAIL@ADDRESS>zLANGUAGE <LL@li.org>�utf-8Nr1zYEAR-MO-DA HO:MI+ZONE)r�r��_header_commentr�	_messagesr�r�r�r�r�r�r�r+�nowrrRr2r8r�r�rv�obsolete�_num_plurals�_plural_expr)rSr�r�r�r�r�r�r�r�r�r�r�r�rvrrrrTs2$






zCatalog.__init__zLocale | str | None)r�r*cCs�|durd|_d|_dSt|t�r6t|�|_||_dSt|t�rxt|�|_zt�|�|_Wntyrd|_Yn0dStd|����dS)NzD`locale` must be a Locale, a locale identifier string, or None; got )�_locale_identifier�_localerRrr(�parser
�	TypeError�rSr�rrr�_set_locale_s 



zCatalog._set_localez
Locale | NonerUcCs|jSrn)r�rZrrr�_get_localetszCatalog._get_localecCs|jSrn)r�rZrrr�_get_locale_identifierwszCatalog._get_locale_identifierr(cCs�|j}tj�t��d�}t|jd�r0|j�d�}|�d|j��d|j	��d|��d|j
�}|jrh|jjn|j
}|r�|�d|�d��}|S)	Nz%Y�strftimer�r��YEARr�zTranslations templatez
 translations)r�r+r�rr��hasattrr�r8r�r�r�r�Zenglish_name�locale_identifier)rSZcommentZyearZlocale_namerrr�_get_header_comment}s���zCatalog._get_header_comment)rDr*cCs
||_dSrn)r�)rSrDrrr�_set_header_comment�szCatalog._set_header_commenta�    The header comment for the catalog.

    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   copyright_holder='Foo Company')
    >>> print(catalog.header_comment) #doctest: +ELLIPSIS
    # Translations template for Foobar.
    # Copyright (C) ... Foo Company
    # This file is distributed under the same license as the Foobar project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, ....
    #

    The header can also be set from a string. Any known upper-case variables
    will be replaced when the header is retrieved again:

    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   copyright_holder='Foo Company')
    >>> catalog.header_comment = '''\
    ... # The POT for my really cool PROJECT project.
    ... # Copyright (C) 1990-2003 ORGANIZATION
    ... # This file is distributed under the same license as the PROJECT
    ... # project.
    ... #'''
    >>> print(catalog.header_comment)
    # The POT for my really cool Foobar project.
    # Copyright (C) 1990-2003 Foo Company
    # This file is distributed under the same license as the Foobar
    # project.
    #

    :type: `unicode`
    )�doczlist[tuple[str, str]]cCsXg}|�d|j�d|j��f�|�d|jf�|�dt|jddd�f�t|jtjtj	t
tf�r~|�dt|jddd�f�n|�d|jf�|�d	|jf�|j
r�|�d
t|j
�f�|j
r�d|jvr�|�d|j�dt|j
��f�n|�d|jf�|jdu�r|�d
|jf�|�d�|�dd|j��f�|�d�|�ddt�d�f�|S)NzProject-Id-VersionrWzReport-Msgid-Bugs-TozPOT-Creation-Datezyyyy-MM-dd HH:mmZ�en)r�zPO-Revision-DatezLast-TranslatorZLanguage�LANGUAGEz
Language-TeamzPlural-Forms)zMIME-Versionz1.0zContent-Typeztext/plain; charset=)zContent-Transfer-EncodingZ8bitzGenerated-ByzBabel �
)r"r�r�r�rr�rRr�r+�timer7�floatr�r�r(r�r8r��plural_formsr�r�)rS�headersrrr�_get_mime_headers�s@������

zCatalog._get_mime_headersr��strictzstr | bytes)r&�encodingrsr*cCs,t|t�r|St|t�r$|�||�St|�Srn)rRr(�bytes�decode)rSr&r�rsrrr�_force_text�s


zCatalog._force_textzIterable[tuple[str, str]])r�r*cCsL|D�]@\}}|j|��|jd�}|j||jd�}|dkrd|�d�}d�|dd��|_|d|_q|dkrt||_q|dkr�||_q|dkr�|�	dd	�}|�
|�q|d
kr�||_q|dkr�t|�}d|vr�|d��|_q|d
k�rtd|���}t
|�dd��|_|�dd�|_q|dk�r,t|�|_q|dkrd|vrt|�|_qdS)N)r�zproject-id-versionrW���zreport-msgid-bugs-tozlast-translator�language�-�_z
language-teamr�r�zplural-formsz ;Znpluralsr.�plural�(n != 1)zpot-creation-datezpo-revision-dater�)r��lowerr��split�joinr�r�r�r�r8r�r�r�r7�getr�r�r:r�r�)rSr��namer)�parts�paramsrrr�_set_mime_headers�s:


zCatalog._set_mime_headersa�    The MIME headers of the catalog, used for the special ``msgid ""`` entry.

    The behavior of this property changes slightly depending on whether a locale
    is set or not, the latter indicating that the catalog is actually a template
    for actual translations.

    Here's an example of the output for such a catalog template:

    >>> from babel.dates import UTC
    >>> from datetime import datetime
    >>> created = datetime(1990, 4, 1, 15, 30, tzinfo=UTC)
    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   creation_date=created)
    >>> for name, value in catalog.mime_headers:
    ...     print('%s: %s' % (name, value))
    Project-Id-Version: Foobar 1.0
    Report-Msgid-Bugs-To: EMAIL@ADDRESS
    POT-Creation-Date: 1990-04-01 15:30+0000
    PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
    Last-Translator: FULL NAME <EMAIL@ADDRESS>
    Language-Team: LANGUAGE <LL@li.org>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit
    Generated-By: Babel ...

    And here's an example of the output when the locale is set:

    >>> revised = datetime(1990, 8, 3, 12, 0, tzinfo=UTC)
    >>> catalog = Catalog(locale='de_DE', project='Foobar', version='1.0',
    ...                   creation_date=created, revision_date=revised,
    ...                   last_translator='John Doe <jd@example.com>',
    ...                   language_team='de_DE <de@example.com>')
    >>> for name, value in catalog.mime_headers:
    ...     print('%s: %s' % (name, value))
    Project-Id-Version: Foobar 1.0
    Report-Msgid-Bugs-To: EMAIL@ADDRESS
    POT-Creation-Date: 1990-04-01 15:30+0000
    PO-Revision-Date: 1990-08-03 12:00+0000
    Last-Translator: John Doe <jd@example.com>
    Language: de_DE
    Language-Team: de_DE <de@example.com>
    Plural-Forms: nplurals=2; plural=(n != 1);
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit
    Generated-By: Babel ...

    :type: `list`
    r7cCs.|jdur(d}|jr"t|j�d}||_|jS)z�The number of plurals used by the catalog or locale.

        >>> Catalog(locale='en').num_plurals
        2
        >>> Catalog(locale='ga').num_plurals
        5

        :type: `int`Nr.r)r�r�r)rSZnumrrr�num_plurals(s

zCatalog.num_pluralscCs.|jdur(d}|jr"t|j�d}||_|jS)aWThe plural expression used by the catalog or locale.

        >>> Catalog(locale='en').plural_expr
        '(n != 1)'
        >>> Catalog(locale='ga').plural_expr
        '(n==1 ? 0 : n==2 ? 1 : n>=3 && n<=6 ? 2 : n>=7 && n<=10 ? 3 : 4)'
        >>> Catalog(locale='ding').plural_expr  # unknown locale
        '(n != 1)'

        :type: `str`Nr�r-)r�r�r)rS�exprrrr�plural_expr9s
zCatalog.plural_exprcCsd|j�d|j�d�S)z�Return the plural forms declaration for the locale.

        >>> Catalog(locale='en').plural_forms
        'nplurals=2; plural=(n != 1);'
        >>> Catalog(locale='pt_BR').plural_forms
        'nplurals=2; plural=(n > 1);'

        :type: `str`z	nplurals=z	; plural=�;)r�r�rZrrrr�Ls
zCatalog.plural_formsr)rCr*cCs|�|�|jvS)z?Return whether the catalog has a message with the specified ID.��_key_forr��rSrCrrr�__contains__XszCatalog.__contains__cCs
t|j�S)zeThe number of messages in the catalog.

        This does not include the special ``msgid ""`` entry.)�lenr�rZrrr�__len__\szCatalog.__len__zIterator[Message]ccspg}|jD]\}}|�|�d|���q
t�}|jr>|dhO}tdd�|�|d�V|jD]}|j|VqZdS)z�Iterates through all the entries in the catalog, in the order they
        were added, yielding a `Message` object for every entry.

        :rtype: ``iterator``z: rvr;r�rwN)�mime_headersr"rNrvrr�r�)rS�bufr�r)rF�keyrrr�__iter__bs

zCatalog.__iter__cCs4d}|jrd|j��}dt|�j�d|j�|�d�S)Nr;rWrV�>)r�rXrYr�r�rrrr[qszCatalog.__repr__cCs|�|�dS)z)Delete the message with the specified ID.N)�deleter�rrr�__delitem__wszCatalog.__delitem__rcCs
|�|�S)zUReturn the message with the specified ID.

        :param id: the message ID
        )r�r�rrr�__getitem__{szCatalog.__getitem__)rC�messager*cCs"t|t�sJd��|�||j�}|j�|�}|r�|jrL|jsL|j|_|j|_t	t
|j|j��|_t	t
|j|j��|_t	t
|j
|j
��|_
|j|jO_|}nz|dkr�t|j���|_d�dd�|j
D��|_|j|_n@t|t	tf��rt|jt	tf��sJdt|j�����||j|<dS)a�Add or update the message with the specified ID.

        >>> catalog = Catalog()
        >>> catalog[u'foo'] = Message(u'foo')
        >>> catalog[u'foo']
        <Message u'foo' (flags: [])>

        If a message with that ID is already in the catalog, it is updated
        to include the locations and flags of the new message.

        >>> catalog = Catalog()
        >>> catalog[u'foo'] = Message(u'foo', locations=[('main.py', 1)])
        >>> catalog[u'foo'].locations
        [('main.py', 1)]
        >>> catalog[u'foo'] = Message(u'foo', locations=[('utils.py', 5)])
        >>> catalog[u'foo'].locations
        [('main.py', 1), ('utils.py', 5)]

        :param id: the message ID
        :param message: the `Message` object
        zexpected a Message objectr;r�cSsg|]}d|�����qS)z# )�rstrip)r�crrrr�r z'Catalog.__setitem__.<locals>.<listcomp>zExpected sequence but got N)rRrr�rKr�r�rLrCrDrMrrErGrHrFr�itemsr�r�r�rvrxrX)rSrCr�r��currentrrr�__setitem__�s6�
�
�

�zCatalog.__setitem__rr<r=r>r?rBc
Cs*t||t|�||||||	d�	}
|
||<|
S)atAdd or update the message with the specified ID.

        >>> catalog = Catalog()
        >>> catalog.add(u'foo')
        <Message ...>
        >>> catalog[u'foo']
        <Message u'foo' (flags: [])>

        This method simply constructs a `Message` object with the given
        arguments and invokes `__setitem__` with that object.

        :param id: the message ID, or a ``(singular, plural)`` tuple for
                   pluralizable messages
        :param string: the translated message string, or a
                       ``(singular, plural)`` tuple for pluralizable messages
        :param locations: a sequence of ``(filename, lineno)`` tuples
        :param flags: a set or sequence of flags
        :param auto_comments: a sequence of automatic comments
        :param user_comments: a sequence of user comments
        :param previous_id: the previous message ID, or a ``(singular, plural)``
                            tuple for pluralizable messages
        :param lineno: the line number on which the msgid line was found in the
                       PO file, if any
        :param context: the message context
        )rJrK)rrM)rSrCrDrErFrGrHrIrJrKr�rrrrP�s%�zCatalog.addz0Iterable[tuple[Message, list[TranslationError]]]ccs.|j��D]}|j|d�}|r
||fVq
dS)a\Run various validation checks on the translations in the catalog.

        For every message which fails validation, this method yield a
        ``(message, errors)`` tuple, where ``message`` is the `Message` object
        and ``errors`` is a sequence of `TranslationError` objects.

        :rtype: ``generator`` of ``(message, errors)``
        )rqN)r��valuesru)rSr�rsrrrru�s	z
Catalog.checkzMessage | None)rCrKr*cCs|j�|�||��S)z�Return the message with the specified ID and context.

        :param id: the message ID
        :param context: the message context, or ``None`` for no context
        )r�r�r�)rSrCrKrrrr��szCatalog.getcCs"|�||�}||jvr|j|=dS)z�Delete the message with the specified ID and context.

        :param id: the message ID
        :param context: the message context, or ``None`` for no context
        Nr��rSrCrKr�rrrr��s
zCatalog.deleteF)�template�no_fuzzy_matching�update_header_comment�keep_user_commentsr*cs��j�����t��_g}|sfi}�D]>}|r&�|jr&��|�}�|j}|����}	||f||	<q&t��ddddd������fdd�}
|D]�}|j	r���|j	|j�}|�vr�|
|||�q�|�s0t
|t�r�|d}n|}t|����|�
�d�}
|
�r0|
d}	||	\}}|d	u�r"||f}|
|||�q�|�|j	<q��D]$}|�sT|�v�r@�|�j|<�q@|�rt|j�_|j�_d	S)
a�Update the catalog based on the given template catalog.

        >>> from babel.messages import Catalog
        >>> template = Catalog()
        >>> template.add('green', locations=[('main.py', 99)])
        <Message ...>
        >>> template.add('blue', locations=[('main.py', 100)])
        <Message ...>
        >>> template.add(('salad', 'salads'), locations=[('util.py', 42)])
        <Message ...>
        >>> catalog = Catalog(locale='de_DE')
        >>> catalog.add('blue', u'blau', locations=[('main.py', 98)])
        <Message ...>
        >>> catalog.add('head', u'Kopf', locations=[('util.py', 33)])
        <Message ...>
        >>> catalog.add(('salad', 'salads'), (u'Salat', u'Salate'),
        ...             locations=[('util.py', 38)])
        <Message ...>

        >>> catalog.update(template)
        >>> len(catalog)
        3

        >>> msg1 = catalog['green']
        >>> msg1.string
        >>> msg1.locations
        [('main.py', 99)]

        >>> msg2 = catalog['blue']
        >>> msg2.string
        u'blau'
        >>> msg2.locations
        [('main.py', 100)]

        >>> msg3 = catalog['salad']
        >>> msg3.string
        (u'Salat', u'Salate')
        >>> msg3.locations
        [('util.py', 42)]

        Messages that are in the catalog but not in the template are removed
        from the main collection, but can still be accessed via the `obsolete`
        member:

        >>> 'head' in catalog
        False
        >>> list(catalog.obsolete.values())
        [<Message 'head' (flags: [])>]

        :param template: the reference catalog, usually read from a POT file
        :param no_fuzzy_matching: whether to use fuzzy matching of message IDs
        r�tuple[str, str] | strrA)r��oldkey�newkeyr*csd|��}d}||kr^d}��|���|�}|dus8J�t|jt�rP|jg|_qvt|j�|_n��|d�}|dusvJ�|j	|_	�r�tt
|j��|_t|jttf��rt|j	ttf�s�d}t|j	gdgt
|j�d�|_	n0t
|j	��jk�r0d}t|j	dt
|j	���|_	n"t|j	ttf��r0d}|j	d|_	|j|jO_|�rV|jdhO_|�|j<dS)NFTr;r-rrv)rprPr�rRrCr(rIrM�poprDrrHrxr�r�rF)r�r�r�rvZoldmsg�Z
fuzzy_matchesr��messagesZ	remainingrSrr�_mergeIs>

�zCatalog.update.<locals>._mergerr-N)r�rrrDr�rKr��striprNrCrRrxr'�keysr�r�r�)rSr�r�r�r�Zfuzzy_candidatesZmsgidr�ZctxtZmodified_keyr�r�Zmatchkey�matchesr�Znewctxtrr�r�update�sP;

 %

�
zCatalog.updater�cCs.|}t|ttf�r|d}|dur*||f}|S)z�The key for a message is just the singular ID even for pluralizable
        messages, but is a ``(msgid, msgctxt)`` tuple for context-specific
        messages.
        rN)rRrMrxr�rrrr��szCatalog._key_forr]cCspt|t�sJ�|j��|j��BD]8}|�|�}|�|�}|dusT|dusT|�|�s"dSq"t|j�t|j�kS)z\Checks if catalogs are identical, taking into account messages and
        headers.
        NF)rRrr�r�r�rmr�r�)rSr^r�Z	message_1Z	message_2rrrrm�s

���zCatalog.is_identical)r�r�)NrrrrrNN)N)N)FFT)N)$rYr}r~r�DEFAULT_HEADERrTr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r[r�r�r�rPrur�r�r�r�rmrrrrrsv�*F
! 44�"+
�r)rr)5rZ
__future__rr+r3�collectionsr�collections.abcrrrZdifflibrZemailr�heapqr	�typingr
Zbabelrr�Z
babel.corerr
Zbabel.datesrZbabel.messages.pluralsrZ
babel.utilrrrrZtyping_extensionsrr(rxrMr�__annotations__�__all__r'�compile�VERBOSEryr:r�	Exceptionrr�r�rrrrr�<module>s<	 
	�

Youez - 2016 - github.com/yon3zu
LinuXploit