
    Mh|k                    H   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZ e	rddlZdd	lmZ dd
lm Z   G d d          Z! G d d          Z" G d dej#                  Z# G d de#ej$                  Z%ddZ&dS )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-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    )annotationsN)Iterator)TYPE_CHECKINGAnyCallableIterableLiteral)Locale)format_dateformat_datetimeformat_timeformat_timedelta)format_compact_currencyformat_compact_decimalformat_currencyformat_decimalformat_percentformat_scientific)Decimal)_PredefinedTimeFormatc                      e Zd ZdZ	 d:ddd;dZ	 	 d<d=dZ	 	 d<d>dZ	 	 d<d?dZ	 	 	 	 d@dAd'ZdBd*Z	d:dCd,Z
	 	 dDdEd3ZdFd5Z	 	 dDdGd7Zd:dCd8ZdBd9ZdS )HFormataC  Wrapper 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'
    Nlatn)numbering_systemlocaleLocale | strtzinfo_datetime.tzinfo | Noner   Literal['default'] | strreturnNonec               T    t          j        |          | _        || _        || _        dS )a  Initialize the formatter.

        :param locale: the locale identifier or `Locale` instance
        :param tzinfo: the time-zone info (a `tzinfo` instance or `None`)
        :param numbering_system: The numbering system used for formatting number symbols. Defaults to "latn".
                                 The special value "default" will use the default numbering system of the locale.
        N)r
   parser   r   r   )selfr   r   r   s       M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/babel/support.py__init__zFormat.__init__4   s*     l6** 0    mediumdate_datetime.date | Noneformat_PredefinedTimeFormat | strstrc                0    t          ||| j                  S )zReturn 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   )r   r   )r$   r)   r+   s      r%   r)   zFormat.dateF   s     4<<<<r'   datetimec                <    t          ||| j        | j                  S )uG  Return a date and time formatted according to the given pattern.

        >>> from datetime import datetime
        >>> from babel.dates import get_timezone
        >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
        >>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
        u'Apr 1, 2007, 11:30:00 AM'
        r   r   )r   r   r   )r$   r/   r+   s      r%   r/   zFormat.datetimeT   s     xDKXXXXr'   time*_datetime.time | _datetime.datetime | Nonec                <    t          ||| j        | j                  S )u-  Return a time formatted according to the given pattern.

        >>> from datetime import datetime
        >>> from babel.dates import get_timezone
        >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
        >>> fmt.time(datetime(2007, 4, 1, 15, 30))
        u'11:30:00 AM'
        r1   )r   r   r   )r$   r2   r+   s      r%   r2   zFormat.timec   s     4DKPPPPr'   second333333?longFdelta_datetime.timedelta | intgranularityCLiteral['year', 'month', 'week', 'day', 'hour', 'minute', 'second']	thresholdfloat,Literal['narrow', 'short', 'medium', 'long']add_directionboolc                6    t          |||||| j                  S )zReturn 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'
        )r:   r<   r+   r?   r   )r   r   )r$   r8   r:   r<   r+   r?   s         r%   	timedeltazFormat.timedeltar   s,      ;*3'-]'+{4 4 4 	4r'   numberfloat | Decimal | strc                :    t          || j        | j                  S )zReturn an integer number formatted for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.number(1099)
        u'1,099'
        r   r   r   r   r   r$   rC   s     r%   rC   zFormat.number   s     fT[4K`aaaar'   
str | Nonec                <    t          ||| j        | j                  S )zReturn a decimal number formatted for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.decimal(1.2345)
        u'1.234'
        rF   rG   r$   rC   r+   s      r%   decimalzFormat.decimal   !     ffT[SWShiiiir'   shortr   format_typeLiteral['short', 'long']fraction_digitsintc                >    t          |||| j        | j                  S )a  Return a number formatted in compact form for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.compact_decimal(123456789)
        u'123M'
        >>> fmt.compact_decimal(1234567, format_type='long', fraction_digits=2)
        '1.23 million'
        rO   rQ   r   r   )r   r   r   )r$   rC   rO   rQ   s       r%   compact_decimalzFormat.compact_decimal   s/     &#+;!2
 
 
 	
r'   currencyc                <    t          ||| j        | j                  S )zHReturn a number in the given currency formatted for the locale.
        rF   )r   r   r   )r$   rC   rV   s      r%   rV   zFormat.currency   s!     vxVZVkllllr'   Literal['short']c                @    t          ||||| j        | j                  S )zReturn a number in the given currency formatted for the locale
        using the compact number format.

        >>> Format('en_US').compact_currency(1234567, "USD", format_type='short', fraction_digits=2)
        '$1.23M'
        rT   )r   r   r   )r$   rC   rV   rO   rQ   s        r%   compact_currencyzFormat.compact_currency   s2     'vx[bq.2kDLac c c 	cr'   c                <    t          ||| j        | j                  S )zReturn a number formatted as percentage for the locale.

        >>> fmt = Format('en_US')
        >>> fmt.percent(0.34)
        u'34%'
        rF   )r   r   r   rK   s      r%   percentzFormat.percent   rM   r'   c                :    t          || j        | j                  S )zLReturn a number formatted using scientific notation for the locale.
        rF   )r   r   r   rH   s     r%   
scientificzFormat.scientific   s     !dNcddddr'   N)r   r   r   r   r   r   r    r!   )Nr(   )r)   r*   r+   r,   r    r-   )r/   r*   r+   r,   r    r-   )r2   r3   r+   r,   r    r-   )r5   r6   r7   F)r8   r9   r:   r;   r<   r=   r+   r>   r?   r@   r    r-   )rC   rD   r    r-   )rC   rD   r+   rI   r    r-   )rN   r   )rC   rD   rO   rP   rQ   rR   r    r-   )rC   rD   rV   r-   r    r-   )
rC   rD   rV   r-   rO   rX   rQ   rR   r    r-   )__name__
__module____qualname____doc__r&   r)   r/   r2   rB   rC   rL   rU   rV   rZ   r\   r^    r'   r%   r   r   '   s       
 
 +/1
 6<1 1 1 1 1 1( '+.6= = = = =  +/.6Y Y Y Y Y" <@.6Q Q Q Q Q$ \d?E#4 4 4 4 4(b b b bj j j j j 18 	
 
 
 
 
,m m m m )0 c c c c c j j j j je e e e e er'   r   c                  Z   e Zd ZU dZg dZerded<   ded<   ded<   d	ed
<   ded<   ded<   ddd?dZed@d            Z	dAdZ
dBdZdCdZdDd ZdEd"ZdFd$ZdGd&ZdGd'ZdGd(ZdGd)ZdGd*ZdGd+ZdHd,ZdId-ZdId.ZdId/ZdId0ZdId1ZdId2ZdJd4ZdKd5ZdLd7ZdMd8Z dNd9Z!dOd:Z"dPd;Z#dQd=Z$d>S )R	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_errorCallable[..., Any]rg   ztuple[Any, ...]rh   zdict[str, Any]ri   r@   rk   r   rj   zAttributeError | Nonerl   T)enable_cachefuncargsrn   kwargsr    r!   c               V   t                               | d|           t                               | d|           t                               | d|           t                               | d|           t                               | dd            t                               | dd            d S )Nrg   rh   ri   rk   rj   rl   )object__setattr__)r$   ro   rn   rp   rq   s        r%   r&   zLazyProxy.__init__   s    4$///4$///4F3334!4lCCC440004!3T:::::r'   c                    | j         m	  | j        | j        i | j        }n/# t          $ r"}t
                              | d|            d }~ww xY w| j        s|S t
                              | d|           | j         S )Nrl   rj   )rj   rg   rh   ri   AttributeErrorrs   rt   rk   )r$   valueerrors      r%   rw   zLazyProxy.value  s    ;"
DJ?$,??!   ""4);UCCC ) tXu555{s   ! 
AAAkeyrs   c                    || j         v S r_   rw   r$   ry   s     r%   __contains__zLazyProxy.__contains__  s    dj  r'   c                *    t          | j                  S r_   )r@   rw   r$   s    r%   __bool__zLazyProxy.__bool__      DJr'   	list[str]c                *    t          | j                  S r_   )dirrw   r   s    r%   __dir__zLazyProxy.__dir__      4:r'   Iterator[Any]c                *    t          | j                  S r_   )iterrw   r   s    r%   __iter__zLazyProxy.__iter__  r   r'   rR   c                *    t          | j                  S r_   )lenrw   r   s    r%   __len__zLazyProxy.__len__"  r   r'   r-   c                *    t          | j                  S r_   )r-   rw   r   s    r%   __str__zLazyProxy.__str__%  r   r'   otherc                    | j         |z   S r_   r{   r$   r   s     r%   __add__zLazyProxy.__add__(      zE!!r'   c                    || j         z   S r_   r{   r   s     r%   __radd__zLazyProxy.__radd__+      tz!!r'   c                    | j         |z  S r_   r{   r   s     r%   __mod__zLazyProxy.__mod__.  r   r'   c                    || j         z  S r_   r{   r   s     r%   __rmod__zLazyProxy.__rmod__1  r   r'   c                    | j         |z  S r_   r{   r   s     r%   __mul__zLazyProxy.__mul__4  r   r'   c                    || j         z  S r_   r{   r   s     r%   __rmul__zLazyProxy.__rmul__7  r   r'   c                     | j         |i |S r_   r{   )r$   rp   rq   s      r%   __call__zLazyProxy.__call__:  s    tz4*6***r'   c                    | j         |k     S r_   r{   r   s     r%   __lt__zLazyProxy.__lt__=      zE!!r'   c                    | j         |k    S r_   r{   r   s     r%   __le__zLazyProxy.__le__@      zU""r'   c                    | j         |k    S r_   r{   r   s     r%   __eq__zLazyProxy.__eq__C  r   r'   c                    | j         |k    S r_   r{   r   s     r%   __ne__zLazyProxy.__ne__F  r   r'   c                    | j         |k    S r_   r{   r   s     r%   __gt__zLazyProxy.__gt__I  r   r'   c                    | j         |k    S r_   r{   r   s     r%   __ge__zLazyProxy.__ge__L  r   r'   namec                0    t          | j        |           d S r_   )delattrrw   r$   r   s     r%   __delattr__zLazyProxy.__delattr__O  s    
D!!!!!r'   c                H    | j         | j         t          | j        |          S r_   )rl   getattrrw   r   s     r%   __getattr__zLazyProxy.__getattr__R  s&     ,''tz4(((r'   rw   c                2    t          | j        ||           d S r_   )setattrrw   )r$   r   rw   s      r%   rt   zLazyProxy.__setattr__W  s    
D%(((((r'   c                    | j         |= d S r_   r{   r|   s     r%   __delitem__zLazyProxy.__delitem__Z  s    JsOOOr'   c                    | j         |         S r_   r{   r|   s     r%   __getitem__zLazyProxy.__getitem__]  s    z#r'   c                    || j         |<   d S r_   r{   )r$   ry   rw   s      r%   __setitem__zLazyProxy.__setitem__`  s    
3r'   c                N    t          | j        g| j        R d| j        i| j        S )Nrn   )rf   rg   rh   rk   ri   r   s    r%   __copy__zLazyProxy.__copy__c  sF    J
 Z
 
 
/
 l	
 
 	
r'   memoc                    ddl m} t           || j        |          g || j        |          R d || j        |          i || j        |          S )Nr   )deepcopyrn   )copyr   rf   rg   rh   rk   ri   )r$   r   r   s      r%   __deepcopy__zLazyProxy.__deepcopy__k  s    !!!!!!HTZ&&
 Xdj$''
 
 
!$"8$??
 ht|T**	
 
 	
r'   N)
ro   rm   rp   r   rn   r@   rq   r   r    r!   )r    r   )ry   rs   r    r@   )r    r@   )r    r   )r    r   )r    rR   r    r-   )r   rs   r    r   )rp   r   rq   r   r    r   )r   rs   r    r@   )r   r-   r    r!   )r   r-   r    r   )r   r-   rw   r   r    r!   )ry   r   r    r!   )ry   r   r    r   )ry   r   rw   r   r    r!   )r    rf   )r   r   r    rf   )%r`   ra   rb   rc   	__slots__r   __annotations__r&   propertyrw   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rt   r   r   r   r   r   rd   r'   r%   rf   rf      s        ! !D a``I 0!!!!////RV ; ; ; ; ; ;    X! ! ! !                       " " " "" " " "" " " "" " " "" " " "" " " "+ + + +" " " "# # # ## # # ## # # #" " " "# # # #" " " ") ) ) )
) ) ) )             
 
 
 

 
 
 
 
 
r'   rf   c                      e Zd ZU er
ded<   ded<   dZd)d* fd
Zd+dZd+dZd+dZ	e	Z
d,dZd,dZd,dZeZdZd-dZd.dZd/dZd0d Zd1d!Zd/d"Zd2d#Zd3d$ZeZd4d%Zd5d&Zd5d'ZeZd6d(Zej        j        Z ej        j!        Z" xZ#S )7NullTranslationszdict[str, str]_infozNullTranslations | None	_fallbackNfp"gettext._TranslationsReader | Noner    r!   c           
         i | _         d | _        t                                          |           t	          t          dt          |dd          g                    | _        | j        | _	        i | _
        dS )a  Initialize 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          | dk              S )N   )rR   )ns    r%   <lambda>z+NullTranslations.__init__.<locals>.<lambda>  s    #a1f++ r'   r   Nr   )_catalogpluralsuperr&   listfilterr   filesDEFAULT_DOMAINdomain_domains)r$   r   	__class__s     r%   r&   zNullTranslations.__init__}  sn     ;=8M8MB&FD(A(A'BCCDD
)57r'   r   r-   messagec                ^    | j                             ||                               |          S )zULike ``gettext()``, but look the message up in the specified
        domain.
        )r   getgettextr$   r   r   s      r%   dgettextzNullTranslations.dgettext  s*     }  ..66w???r'   c                    ddl }|                    dt          d           | j                            ||                               |          S )zVLike ``lgettext()``, but look the message up in the specified
        domain.
        r   Nz1ldgettext() is deprecated, use dgettext() instead   
stacklevel)warningswarnDeprecationWarningr   r   lgettext)r$   r   r   r   s       r%   	ldgettextzNullTranslations.ldgettext  sY     	? 	 	
 	
 	

 }  ..77@@@r'   c                ^    | j                             ||                               |          S )zVLike ``ugettext()``, but look the message up in the specified
        domain.
        )r   r   ugettextr   s      r%   	udgettextzNullTranslations.udgettext  s*     }  ..77@@@r'   singularr   numrR   c                b    | j                             ||                               |||          S )zVLike ``ngettext()``, but look the message up in the specified
        domain.
        )r   r   ngettextr$   r   r   r   r   s        r%   	dngettextzNullTranslations.dngettext  s.     }  ..77&#NNNr'   c                    ddl }|                    dt          d           | j                            ||                               |||          S )zWLike ``lngettext()``, but look the message up in the specified
        domain.
        r   Nz3ldngettext() is deprecated, use dngettext() insteadr   r   )r   r   r   r   r   	lngettext)r$   r   r   r   r   r   s         r%   
ldngettextzNullTranslations.ldngettext  s]     	A 	 	
 	
 	

 }  ..8863OOOr'   c                b    | j                             ||                               |||          S )zVLike ``ungettext()`` but look the message up in the specified
        domain.
        )r   r   	ungettextr   s        r%   
udngettextzNullTranslations.udngettext  s.     }  ..8863OOOr'   z%s%scontextstr | objectc                (   | j         ||fz  }t                      }| j                            ||          }||u r0| j                            ||                     d          f|          }||ur|S | j        r| j                            ||          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.
        r   )CONTEXT_ENCODINGrs   r   r   r   r   pgettext)r$   r   r   ctxt_msg_idmissingtmsgs         r%   r  zNullTranslations.pgettext  s     +w.@@((}  g667??=$$k4;;q>>%BGLLDwK> 	=>**7G<<<r'   str | bytes | objectc                   ddl }|                    dt          d           |                     ||          }t	          | dd          pt          j                    }t          |t                    r|	                    |          n|S )zEquivalent to ``pgettext()``, but the translation is returned in the
        preferred system encoding, if no other encoding was explicitly set with
        ``bind_textdomain_codeset()``.
        r   Nz1lpgettext() is deprecated, use pgettext() insteadr   r   _output_charset)
r   r   r   r  r   r   getpreferredencoding
isinstancer-   encode)r$   r   r   r   r  encodings         r%   	lpgettextzNullTranslations.lpgettext  s    
 	? 	 	
 	
 	

 }}Wg..4!2D99ZV=X=Z=Z(24(=(=Gt{{8$$$4Gr'   c                    | j         ||fz  }	 | j        ||                     |          f         }|S # t          $ r5 | j        r| j                            ||||          cY S |dk    r|cY S |cY S w xY w)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)r$   r   r   r   r   r  r  s          r%   r  zNullTranslations.npgettext  s     +w.AA		=+t{{3/?/?!@ADK 	 	 	~ P~//63OOOOOaxx	s   #2 .A1"A1,A10A1str | bytesc                   ddl }|                    dt          d           | j        ||fz  }	 | j        ||                     |          f         }t          | dd          pt          j                    }|	                    |          S # t          $ r5 | j        r| j                            ||||          cY S |dk    r|cY S |cY S w xY w)zEquivalent to ``npgettext()``, but the translation is returned in the
        preferred system encoding, if no other encoding was explicitly set with
        ``bind_textdomain_codeset()``.
        r   Nz3lnpgettext() is deprecated, use npgettext() insteadr   r   r	  r   )r   r   r   r  r   r   r   r   r
  r  r  r   
lnpgettext)	r$   r   r   r   r   r   r  r  r  s	            r%   r  zNullTranslations.lnpgettext  s    
 	A 	 	
 	
 	

 +w.AA
	=+t{{3/?/?!@ADt%6==^A\A^A^H;;x((( 	 	 	~ Q~00(FCPPPPPaxx	s   AB
 
.C	:C	C	C	c                   | j         ||fz  }t                      }| j                            ||          }||u r1| j        r| j                            ||          S t          |          S t          |t                    sJ |S )as  Look 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  rs   r   r   r   	upgettextr-   r  )r$   r   r   ctxt_message_idr  r  s         r%   r  zNullTranslations.upgettext  s     /7G2DD((}  '::7??~ B~//AAAw<<$$$$$$r'   c                   | j         ||fz  }	 | j        ||                     |          f         }nZ# t          $ rM | j        r| j                            ||||          cY S |dk    rt          |          nt          |          }Y nw xY w|S )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   
unpgettextr-   )r$   r   r   r   r   r  r  s          r%   r  zNullTranslations.unpgettext+  s     /7H2EE	>=/4;;s3C3C!DEDD 	> 	> 	>~ Q~00(FCPPPPP$'1HH3x===#f++DDD	> s   "1 .B!$BBc                `    | j                             ||                               ||          S )zVLike `pgettext()`, but look the message up in the specified
        `domain`.
        )r   r   r  r$   r   r   r   s       r%   	dpgettextzNullTranslations.dpgettext?  s,     }  ..77IIIr'   c                `    | j                             ||                               ||          S )zWLike `upgettext()`, but look the message up in the specified
        `domain`.
        )r   r   r  r  s       r%   
udpgettextzNullTranslations.udpgettextE  s,     }  ..88'JJJr'   c                `    | j                             ||                               ||          S )zEquivalent 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%   
ldpgettextzNullTranslations.ldpgettextM  s,    
 }  ..88'JJJr'   c                d    | j                             ||                               ||||          S )zWLike ``npgettext``, but look the message up in the specified
        `domain`.
        )r   r   r  r$   r   r   r   r   r   s         r%   
dnpgettextzNullTranslations.dnpgettextT  s:     }  ..88(9?F F 	Fr'   c                d    | j                             ||                               ||||          S )zXLike ``unpgettext``, but look the message up in the specified
        `domain`.
        )r   r   r  r"  s         r%   udnpgettextzNullTranslations.udnpgettext[  s:     }  ..99'8:@#G G 	Gr'   c                d    | j                             ||                               ||||          S )zEquivalent 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%   ldnpgettextzNullTranslations.ldnpgettextd  s:    
 }  ..99'8:@#G G 	Gr'   r_   )r   r   r    r!   )r   r-   r   r-   r    r-   )
r   r-   r   r-   r   r-   r   rR   r    r-   )r   r-   r   r-   r    r   )r   r-   r   r-   r    r  )
r   r-   r   r-   r   r-   r   rR   r    r-   )
r   r-   r   r-   r   r-   r   rR   r    r  )r   r-   r   r-   r    r-   )r   r-   r   r-   r   r-   r    r   )r   r-   r   r-   r   r-   r    r-   )r   r-   r   r-   r   r-   r    r  )r   r-   r   r-   r   r-   r   r-   r   rR   r    r-   )r   r-   r   r-   r   r-   r   r-   r   rR   r    r  )$r`   ra   rb   r   r   r   r&   r   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   @r%   r   r   u  s5         +****N8 8 8 8 8 8 8"@ @ @ @
A 
A 
A 
AA A A A IO O O O
P 
P 
P 
PP P P P J "   &H H H H   .   0   "   (J J J JK K K K JK K K KF F F FG G G G KG G G G '/H(1IIIIIr'   r   c                       e Zd ZdZdZdd fdZej        j        Zej        j	        Z
e	 	 	 ddd            ZddZdddZddZ xZS ) Translationsz&An extended translation catalog class.messagesNr   r   r   rI   c                h    t                                          |           |p| j        | _        dS )zInitialize 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   r&   r   r   )r$   r   r   r   s      r%   r&   zTranslations.__init__u  s3     	B3 3r'   dirnamestr | os.PathLike[str] | Nonelocales,Iterable[str | Locale] | Locale | str | Noner    r   c                    |s| j         }t          j        ||t          |                    }|st	                      S t          |d          5 } | ||          cddd           S # 1 swxY w Y   dS )ap  Load 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')
        rb)r   r   N)r   r   find_locales_to_namesr   open)clsr2  r4  r   filenamer   s         r%   loadzTranslations.load  s      	('F<1B71K1KLL 	&#%%%(D!! 	-R3"V,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   A''A+.A+r-   c                l    | j                             d          }dt          |           j         d| dS )Nzproject-id-version<z: "z">)r   r   typer`   )r$   versions     r%   __repr__zTranslations.__repr__  s8    *..!56664::&6676666r'   Ttranslationsmerger@   c                B   t          |d| j                  }|r || j        k    r|                     |          S | j                            |          }|r+t          |t                    r|                    |           n|                    |            || 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   rD  r   r   r  r/  add_fallback)r$   rC  rD  r   existings        r%   addzTranslations.add  s     x1DEE 	,Vt{**::l+++=$$V,, 	1Z,77 	1NN<((((%%d+++$0DM&!r'   c                    t          |t          j                  rS| j                            |j                   t          |t
                    r| j                            |j                   | S )a0  Merge 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
        )r  r   GNUTranslationsr   updater/  r   extend)r$   rC  s     r%   rD  zTranslations.merge  sb     lG$;<< 	6M  !6777,55 6
!!,"4555r'   )NN)r   r   r   rI   )NNN)r2  r3  r4  r5  r   rI   r    r   r   )T)rC  r/  rD  r@   )rC  r/  )r`   ra   rb   rc   r   r&   r   rJ  r   r   r   classmethodr=  rB  rH  rD  r,  r-  s   @r%   r/  r/  p  s        00N4 4 4 4 4 4 4 &.H'0I 26@D!	- - - - [-,7 7 7 7    4       r'   r/  r4  r5  r    list[str] | Nonec                    | dS t          | t                    rt          |           gS t          | t                    r| gS d | D             S )zNormalize a `locales` argument to a list of locale names.

    :param locales: the list of locales in order of preference (items in
                    this list can be either `Locale` objects or locale
                    strings)
    Nc                ,    g | ]}t          |          S rd   )r-   ).0r   s     r%   
<listcomp>z%_locales_to_names.<locals>.<listcomp>  s    ...FCKK...r'   )r  r
   r-   )r4  s    r%   r9  r9    s\     t'6"" G~'3 y..g....r'   )r4  r5  r    rN  )'rc   
__future__r   r   r   oscollections.abcr   typingr   r   r   r   r	   
babel.corer
   babel.datesr   r   r   r   babel.numbersr   r   r   r   r   r   r/   	_datetimerL   r   r   r   rf   r   rJ  r/  r9  rd   r'   r%   <module>r[     s1    # " " " " "   				 $ $ $ $ $ $ B B B B B B B B B B B B B B       S S S S S S S S S S S S                 2    111111he he he he he he he heV`
 `
 `
 `
 `
 `
 `
 `
Fx2 x2 x2 x2 x2w/ x2 x2 x2vT T T T T#W%< T T Tn/ / / / / /r'   