%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�x`e�V����dZddlZddlZddlmZddlmZmZmZm	Z	ddl
mZmZm
Z
mZGd�d�ZGd�d	�ZGd
�dej"�ZGd�d
eej$�Zy)a-
    babel.support
    ~~~~~~~~~~~~~

    Several classes and functions that help with integrating and using Babel
    in applications.

    .. note: the code in this module is not used by Babel itself

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�Locale)�format_date�format_datetime�format_time�format_timedelta)�format_decimal�format_currency�format_percent�format_scientificc�^�eZdZdZd
d�Zdd�Zdd�Zdd�Z		dd�Zd�Z	d
d	�Z
d
�Zd
d�Zd�Z
y)�FormataCWrapper class providing the various date and number formatting functions
    bound to a specific locale and time-zone.

    >>> from babel.util import UTC
    >>> from datetime import date
    >>> fmt = Format('en_US', UTC)
    >>> fmt.date(date(2007, 4, 1))
    u'Apr 1, 2007'
    >>> fmt.decimal(1.2345)
    u'1.234'
    Nc�F�tj|�|_||_y)z�Initialize the formatter.

        :param locale: the locale identifier or `Locale` instance
        :param tzinfo: the time-zone info (a `tzinfo` instance or `None`)
        N)r�parse�locale�tzinfo)�selfrrs   �//usr/lib/python3/dist-packages/babel/support.py�__init__zFormat.__init__%s���l�l�6�*������c�2�t|||j��S)z�Return a date formatted according to the given pattern.

        >>> from datetime import date
        >>> fmt = Format('en_US')
        >>> fmt.date(date(2007, 4, 1))
        u'Apr 1, 2007'
        �r)rr)r�date�formats   rrzFormat.date.s���4�����<�<rc�H�t|||j|j��S)a<Return a date and time formatted according to the given pattern.

        >>> from datetime import datetime
        >>> from pytz import timezone
        >>> fmt = Format('en_US', tzinfo=timezone('America/New_York'))
        >>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
        u'Apr 1, 2007, 11:30:00 AM'
        �rr)rrr)r�datetimers   rrzFormat.datetime8s"���x�����&*�k�k�3�	3rc�H�t|||j|j��S)a"Return a time formatted according to the given pattern.

        >>> from datetime import datetime
        >>> from pytz import timezone
        >>> fmt = Format('en_US', tzinfo=timezone('America/New_York'))
        >>> fmt.time(datetime(2007, 4, 1, 15, 30))
        u'11:30:00 AM'
        r)rrr)r�timers   rrzFormat.timeDs���4�����D�K�K�P�Prc�8�t||||||j��S)z�Return a time delta according to the rules of the given locale.

        >>> from datetime import timedelta
        >>> fmt = Format('en_US')
        >>> fmt.timedelta(timedelta(weeks=11))
        u'3 months'
        )�granularity�	thresholdr�
add_directionr)rr)r�deltar r!rr"s      r�	timedeltazFormat.timedeltaOs$�� ��;�*3�'-�]�'+�{�{�4�	4rc�0�t||j��S)z�Return an integer number formatted for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.number(1099)
        u'1,099'
        r�rr�r�numbers  rr(z
Format.number]s���f�T�[�[�9�9rc�2�t|||j��S)z�Return a decimal number formatted for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.decimal(1.2345)
        u'1.234'
        rr&�rr(rs   r�decimalzFormat.decimalf����f�f�T�[�[�A�Arc�2�t|||j��S)zHReturn a number in the given currency formatted for the locale.
        r)r	r)rr(�currencys   rr.zFormat.currencyos���v�x����D�Drc�2�t|||j��S)z�Return a number formatted as percentage for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.percent(0.34)
        u'34%'
        r)r
rr*s   r�percentzFormat.percenttr,rc�0�t||j��S)zLReturn a number formatted using scientific notation for the locale.
        r)rrr's  r�
scientificzFormat.scientific}s��!�����<�<r�N)N�medium)�secondg333333�?�longF)�__name__�
__module__�__qualname__�__doc__rrrrr$r(r+r.r0r2�rrr
r
sG��
��=�
3�	Q�@C�/4�4�:�B�E�
B�=rr
c���eZdZdZgd�Zd�Zed��Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#y!)"�	LazyProxya�Class for proxy objects that delegate to a specified function to evaluate
    the actual object.

    >>> def greeting(name='world'):
    ...     return 'Hello, %s!' % name
    >>> lazy_greeting = LazyProxy(greeting, name='Joe')
    >>> print(lazy_greeting)
    Hello, Joe!
    >>> u'  ' + lazy_greeting
    u'  Hello, Joe!'
    >>> u'(%s)' % lazy_greeting
    u'(Hello, Joe!)'

    This can be used, for example, to implement lazy translation functions that
    delay the actual translation until the string is actually used. The
    rationale for such behavior is that the locale of the user may not always
    be available. In web applications, you only know the locale when processing
    a request.

    The proxy implementation attempts to be as complete as possible, so that
    the lazy objects should mostly work as expected, for example for sorting:

    >>> greetings = [
    ...     LazyProxy(greeting, 'world'),
    ...     LazyProxy(greeting, 'Joe'),
    ...     LazyProxy(greeting, 'universe'),
    ... ]
    >>> greetings.sort()
    >>> for greeting in greetings:
    ...     print(greeting)
    Hello, Joe!
    Hello, universe!
    Hello, world!
    )�_func�_args�_kwargs�_value�_is_cache_enabled�_attribute_errorc�<�|jdd�}tj|d|�tj|d|�tj|d|�tj|d|�tj|dd�tj|dd�y)	N�enable_cacheTr>r?r@rBrArC)�pop�object�__setattr__)r�func�args�kwargs�is_cache_enableds     rrzLazyProxy.__init__�s���!�:�:�n�d�;�����4��$�/����4��$�/����4��F�3����4�!4�6F�G����4��4�0����4�!3�T�:rc��|j�L	|j|ji|j��}|js|St
j
|d|�|jS#t$r}t
j
|d|��d}~wwxYw)NrCrA)rAr>r?r@�AttributeErrorrGrHrB)r�value�errors   rrOzLazyProxy.value�s����;�;��
�"��
�
�D�J�J�?�$�,�,�?��
�)�)������t�X�u�5��{�{���"�
��"�"�4�);�U�C���
�s�&A%�%	B�.B�Bc��||jvSr3�rO�r�keys  r�__contains__zLazyProxy.__contains__�s���d�j�j� � rc�,�t|j�Sr3)�boolrO�rs r�__nonzero__zLazyProxy.__nonzero__�����D�J�J��rc�,�t|j�Sr3)�dirrOrXs r�__dir__zLazyProxy.__dir__�����4�:�:��rc�,�t|j�Sr3)�iterrOrXs r�__iter__zLazyProxy.__iter__�rZrc�,�t|j�Sr3)�lenrOrXs r�__len__zLazyProxy.__len__�r^rc�,�t|j�Sr3)�strrOrXs r�__str__zLazyProxy.__str__�r^rc�,�t|j�Sr3)�unicoderOrXs r�__unicode__zLazyProxy.__unicode__�s���t�z�z�"�"rc� �|j|zSr3rR�r�others  r�__add__zLazyProxy.__add__�����z�z�E�!�!rc� �||jzSr3rRrls  r�__radd__zLazyProxy.__radd__�����t�z�z�!�!rc� �|j|zSr3rRrls  r�__mod__zLazyProxy.__mod__�rorc� �||jzSr3rRrls  r�__rmod__zLazyProxy.__rmod__�rrrc� �|j|zSr3rRrls  r�__mul__zLazyProxy.__mul__�rorc� �||jzSr3rRrls  r�__rmul__zLazyProxy.__rmul__�rrrc�&�|j|i|��Sr3rR)rrJrKs   r�__call__zLazyProxy.__call__�s���t�z�z�4�*�6�*�*rc� �|j|kSr3rRrls  r�__lt__zLazyProxy.__lt__�rorc� �|j|kSr3rRrls  r�__le__zLazyProxy.__le__�����z�z�U�"�"rc� �|j|k(Sr3rRrls  r�__eq__zLazyProxy.__eq__�r�rc� �|j|k7Sr3rRrls  r�__ne__zLazyProxy.__ne__�r�rc� �|j|kDSr3rRrls  r�__gt__zLazyProxy.__gt__�rorc� �|j|k\Sr3rRrls  r�__ge__zLazyProxy.__ge__�r�rc�0�t|j|�yr3)�delattrrO�r�names  r�__delattr__zLazyProxy.__delattr__�s����
�
�D�!rc�^�|j�|j�t|j|�Sr3)rC�getattrrOr�s  r�__getattr__zLazyProxy.__getattr__�s+��� � �,��'�'�'��t�z�z�4�(�(rc�2�t|j||�yr3)�setattrrO)rr�rOs   rrHzLazyProxy.__setattr__s����
�
�D�%�(rc��|j|=yr3rRrSs  r�__delitem__zLazyProxy.__delitem__s
���J�J�s�Orc� �|j|Sr3rRrSs  r�__getitem__zLazyProxy.__getitem__
s���z�z�#��rc�"�||j|<yr3rR)rrTrOs   r�__setitem__zLazyProxy.__setitem__
s����
�
�3�rc�t�t|jg|j��d|ji|j��S)NrE)r=r>r?rBr@rXs r�__copy__zLazyProxy.__copy__s@����J�J�
��Z�Z�
��/�/�
��l�l�	
�	
rc��ddlm}t||j|�g||j|���d||j
|�i||j|���S)Nr)�deepcopyrE)�copyr�r=r>r?rBr@)r�memor�s   r�__deepcopy__zLazyProxy.__deepcopy__s_��!���T�Z�Z��&�
��d�j�j�$�
'�
�!�$�"8�"8�$�?�
��t�|�|�T�*�	
�	
rN)$r7r8r9r:�	__slots__r�propertyrOrUrYr]rardrgrjrnrqrtrvrxrzr|r~r�r�r�r�r�r�r�rHr�r�r�r�r�r;rrr=r=�s���!�Da�I�;�����!� �� ���#�"�"�"�"�"�"�+�"�#�#�#�"�#�"�)�
)��� �
�
rr=c���eZdZdZd�fd�	Zd�Zd�Zd�ZeZd�Z	d�Z
d�ZeZd	Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�ZeZd�Zd�Zd�ZeZd�Zej:j8Zej:j>Z �xZ!S)�NullTranslationsNc
���i|_d�|_t�|�
|��t	tdt
|dd�g��|_|j|_	i|_
y)aInitialize a simple translations class which is not backed by a
        real catalog. Behaves similar to gettext.NullTranslations but also
        offers Babel's on *gettext methods (e.g. 'dgettext()').

        :param fp: a file-like object (ignored in this class)
        c��t|dk7�S)N�)�int)�ns r�<lambda>z+NullTranslations.__init__.<locals>.<lambda>1s���A��F��r��fpNr�)�_catalog�plural�superr�list�filterr��files�DEFAULT_DOMAIN�domain�_domains)rr��	__class__s  �rrzNullTranslations.__init__&sV�����
�+���
���B����&����F�D�(A�'B�C�D��
��)�)�����
rc�X�|jj||�j|�S)zULike ``gettext()``, but look the message up in the specified
        domain.
        )r��get�gettext�rr��messages   r�dgettextzNullTranslations.dgettext7s&���}�}� � ���.�6�6�w�?�?rc��ddl}|jdtd�|jj	||�j|�S)zVLike ``lgettext()``, but look the message up in the specified
        domain.
        rNz1ldgettext() is deprecated, use dgettext() instead�)�warnings�warn�DeprecationWarningr�r��lgettext)rr�r�r�s    r�	ldgettextzNullTranslations.ldgettext=s=��	��
�
�I�(�!�	-��}�}� � ���.�7�7��@�@rc�X�|jj||�j|�S)zVLike ``ugettext()``, but look the message up in the specified
        domain.
        )r�r��ugettextr�s   r�	udgettextzNullTranslations.udgettextFs&���}�}� � ���.�7�7��@�@rc�\�|jj||�j|||�S)zVLike ``ngettext()``, but look the message up in the specified
        domain.
        )r�r��ngettext�rr��singularr��nums     r�	dngettextzNullTranslations.dngettextNs*���}�}� � ���.�7�7��&�#�N�Nrc��ddl}|jdtd�|jj	||�j|||�S)zWLike ``lngettext()``, but look the message up in the specified
        domain.
        rNz3ldngettext() is deprecated, use dngettext() insteadr�)r�r�r�r�r��	lngettext)rr�r�r�r�r�s      r�
ldngettextzNullTranslations.ldngettextTsA��	��
�
�K�(�!�	-��}�}� � ���.�8�8��6�3�O�Orc�\�|jj||�j|||�S)zVLike ``ungettext()`` but look the message up in the specified
        domain.
        )r�r��	ungettextr�s     r�
udngettextzNullTranslations.udngettext]s*���}�}� � ���.�8�8��6�3�O�Orz%s%sc���|j||fz}t�}|jj||�}||ur*|jr|jj||�S|S|S)a�Look up the `context` and `message` id in the catalog and return the
        corresponding message string, as an 8-bit string encoded with the
        catalog's charset encoding, if known.  If there is no entry in the
        catalog for the `message` id and `context` , and a fallback has been
        set, the look up is forwarded to the fallback's ``pgettext()``
        method. Otherwise, the `message` id is returned.
        )�CONTEXT_ENCODINGrGr�r��	_fallback�pgettext)r�contextr��ctxt_msg_id�missing�tmsgs      rr�zNullTranslations.pgettextlse���+�+�w��.@�@���(���}�}� � ��g�6���7�?��~�~��~�~�.�.�w��@�@��N��rc���ddl}|jdtd�|j||�}t	|dd�xstj�}|j|�S)z�Equivalent to ``pgettext()``, but the translation is returned in the
        preferred system encoding, if no other encoding was explicitly set with
        ``bind_textdomain_codeset()``.
        rNz1lpgettext() is deprecated, use pgettext() insteadr��_output_charset)r�r�r�r�r�r�getpreferredencoding�encode)rr�r�r�r��encodings      r�	lpgettextzNullTranslations.lpgettext}sW��
	��
�
�I�(�!�	-��}�}�W�g�.���4�!2�D�9�Z�V�=X�=X�=Z���{�{�8�$�$rc��|j||fz}	|j||j|�f}|S#t$r:|jr |jj||||�cYS|dk(r|cYS|cYSwxYw)a^Do a plural-forms lookup of a message id.  `singular` is used as the
        message id for purposes of lookup in the catalog, while `num` is used to
        determine which plural form to use.  The returned message string is an
        8-bit string encoded with the catalog's charset encoding, if known.

        If the message id for `context` is not found in the catalog, and a
        fallback is specified, the request is forwarded to the fallback's
        ``npgettext()`` method.  Otherwise, when ``num`` is 1 ``singular`` is
        returned, and ``plural`` is returned in all other cases.
        r�)r�r�r��KeyErrorr��	npgettext)rr�r�r�r�r�r�s       rr�zNullTranslations.npgettext�s����+�+�w��.A�A��		��=�=�+�t�{�{�3�/?�!@�A�D��K���	��~�~��~�~�/�/���6�3�O�O��a�x����
�
	�s�!5�3A8�*A8�3A8�7A8c��ddl}|jdtd�|j||fz}	|j||j|�f}t
|dd�xstj�}|j|�S#t$r:|jr |jj||||�cYS|dk(r|cYS|cYSwxYw)z�Equivalent to ``npgettext()``, but the translation is returned in the
        preferred system encoding, if no other encoding was explicitly set with
        ``bind_textdomain_codeset()``.
        rNz3lnpgettext() is deprecated, use npgettext() insteadr�r�r�)
r�r�r�r�r�r�r�rr�r�r�r��
lnpgettext)	rr�r�r�r�r�r�r�r�s	         rr�zNullTranslations.lnpgettext�s���
	��
�
�K�(�!�	-��+�+�w��.A�A��
	��=�=�+�t�{�{�3�/?�!@�A�D��t�%6��=�^��A\�A\�A^�H��;�;�x�(�(���	��~�~��~�~�0�0��(�F�C�P�P��a�x����
�
	�s�AB�3C�7C�C�Cc���|j||fz}t�}|jj||�}||ur3|jr|jj||�St
|�S|S)asLook up the `context` and `message` id in the catalog and return the
        corresponding message string, as a Unicode string.  If there is no entry
        in the catalog for the `message` id and `context`, and a fallback has
        been set, the look up is forwarded to the fallback's ``upgettext()``
        method.  Otherwise, the `message` id is returned.
        )r�rGr�r�r��	upgettextrf)rr�r��ctxt_message_idr�r�s      rr�zNullTranslations.upgettext�sj���/�/�7�G�2D�D���(���}�}� � ��'�:���7�?��~�~��~�~�/�/���A�A��w�<���rc��|j||fz}	|j||j|�f}|S#t$rN|jr |jj||||�cYS|dk(rt
|�}Y|St
|�}Y|SwxYw)a$Do a plural-forms lookup of a message id.  `singular` is used as the
        message id for purposes of lookup in the catalog, while `num` is used to
        determine which plural form to use.  The returned message string is a
        Unicode string.

        If the message id for `context` is not found in the catalog, and a
        fallback is specified, the request is forwarded to the fallback's
        ``unpgettext()`` method.  Otherwise, when `num` is 1 `singular` is
        returned, and `plural` is returned in all other cases.
        r�)r�r�r�r�r��
unpgettextrf)rr�r�r�r�r�r�s       rr�zNullTranslations.unpgettext�s����/�/�7�H�2E�E��	#��=�=�/�4�;�;�s�3C�!D�E�D�����	#��~�~��~�~�0�0��(�F�C�P�P��a�x��8�}�����6�{����	#�s� 5�3B�*B�=B�Bc�Z�|jj||�j||�S)zVLike `pgettext()`, but look the message up in the specified
        `domain`.
        )r�r�r��rr�r�r�s    r�	dpgettextzNullTranslations.dpgettext�s(���}�}� � ���.�7�7���I�Irc�Z�|jj||�j||�S)zWLike `upgettext()`, but look the message up in the specified
        `domain`.
        )r�r�r�r�s    r�
udpgettextzNullTranslations.udpgettext�s(���}�}� � ���.�8�8��'�J�Jrc�Z�|jj||�j||�S)z�Equivalent to ``dpgettext()``, but the translation is returned in the
        preferred system encoding, if no other encoding was explicitly set with
        ``bind_textdomain_codeset()``.
        )r�r�r�r�s    r�
ldpgettextzNullTranslations.ldpgettext�s(��
�}�}� � ���.�8�8��'�J�Jrc�^�|jj||�j||||�S)zWLike ``npgettext``, but look the message up in the specified
        `domain`.
        )r�r�r��rr�r�r�r�r�s      r�
dnpgettextzNullTranslations.dnpgettext�s3���}�}� � ���.�8�8��(�9?��F�	Frc�^�|jj||�j||||�S)zXLike ``unpgettext``, but look the message up in the specified
        `domain`.
        )r�r�r�r�s      r�udnpgettextzNullTranslations.udnpgettext�s3���}�}� � ���.�9�9�'�8�:@�#�G�	Grc�^�|jj||�j||||�S)z�Equivalent to ``dnpgettext()``, but the translation is returned in
        the preferred system encoding, if no other encoding was explicitly set
        with ``bind_textdomain_codeset()``.
        )r�r�r�r�s      r�ldnpgettextzNullTranslations.ldnpgettexts3��
�}�}� � ���.�9�9�'�8�:@�#�G�	Grr3)"r7r8r9r�rr�r�r��	dugettextr�r�r��
dungettextr�r�r�r�r�r�r�r�r��
dupgettextr�r�r��dunpgettextr�r�r�r�r�r��
__classcell__�r�s@rr�r�"s�����N��"@�A�A��I�O�P�P��J�"���"
%��.�*� �.J�K��J�K�F�G��K�G��'�'�/�/�H��(�(�1�1�Irr�c���eZdZdZdZd�fd�	ZejjZejjZ
ed	d��Zd�Z
d
d�Zd�Z�xZS)�Translationsz&An extended translation catalog class.�messagesc�P��t�|�|��|xs|j|_y)z�Initialize the translations catalog.

        :param fp: the file-like object the translation should be read from
        :param domain: the message domain (default: 'messages')
        r�N)r�rr�r�)rr�r�r�s   �rrzTranslations.__init__s'���	���B����3�� 3� 3��rc�,�|�1t|ttf�s|g}|D�cgc]
}t|���}}|s|j}tj|||�}|s
t�St|d�5}|||��cddd�Scc}w#1swYyxYw)apLoad translations from the given directory.

        :param dirname: the directory containing the ``MO`` files
        :param locales: the list of locales in order of preference (items in
                        this list can be either `Locale` objects or locale
                        strings)
        :param domain: the message domain (default: 'messages')
        N�rb)r�r�)	�
isinstancer��tuplerfr�r��findr��open)�cls�dirname�localesr�r�filenamer�s       r�loadzTranslations.loads������g��e�}�5�"�)��18�9�v�s�6�{�9�G�9���'�'�F��<�<����9���#�%�%�
�(�D�
!�	-�R��"�V�,�	-�	-��
:�	-�	-�s�B�1
B
�
Bc�l�dt|�j�d|jjd��d�S)N�<z: "zproject-id-versionz">)�typer7�_infor�rXs r�__repr__zTranslations.__repr__4s,��#�D�z�2�2�#�z�z�~�~�.B�C�E�	Erc��t|d|j�}|r ||jk(r|j|�S|jj|�}|r|�|j|�|S|j
|�||j|<|S)a!Add the given translations to the catalog.

        If the domain of the translations is different than that of the
        current catalog, they are added as a catalog that is only accessible
        by the various ``d*gettext`` functions.

        :param translations: the `Translations` instance with the messages to
                             add
        :param merge: whether translations for message domains that have
                      already been added should be merged with the existing
                      translations
        r�)r�r�r��merger�r��add_fallback)r�translationsrr��existings     r�addzTranslations.add8s�����x��1D�1D�E���V�t�{�{�*��:�:�l�+�+��=�=�$�$�V�,���X�)��N�N�<�(�
��
�%�%�d�+�$0�D�M�M�&�!��rc���t|tj�rZ|jj	|j�t|t
�r%|jj|j�|S)a0Merge the given translations into the catalog.

        Message translations in the specified catalog override any messages
        with the same identifier in the existing catalog.

        :param translations: the `Translations` instance with the messages to
                             merge
        )rr��GNUTranslationsr��updaterr��extend)rrs  rrzTranslations.mergeRsS���l�G�$;�$;�<��M�M� � ��!6�!6�7��,��5��
�
�!�!�,�"4�"4�5��r)NN)NNN)T)r7r8r9r:r�rr�rr�r�r��classmethodr
rrrr�r�s@rrr
sV���0��N�4��&�&�.�.�H��'�'�0�0�I��-��-�*E��4rr)r:r�r�
babel.corer�babel.datesrrrr�
babel.numbersrr	r
rr
r=r�rrr;rr�<module>r!so����
����&�&�h=�h=�V\
�\
�~h2�w�/�/�h2�VS�#�W�%<�%<�Sr

Zerion Mini Shell 1.0