
    Mh#                       U d Z ddlmZ ddlZddl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 ddlmZ ddlmZ ddlmZ i Zd	ed
<    ej                    Zej                            ej                            e          d          Z ej        dej                  Zd'dZ d(dZ!d)dZ" ed          d*d            Z#d)dZ$d+d,dZ%d-d"Z& G d# d$          Z' G d% d&e	j                  Z(dS ).aG  
    babel.localedata
    ~~~~~~~~~~~~~~~~

    Low-level locale data access.

    :note: The `Locale` class, which uses this module under the hood, provides a
           more convenient interface for accessing the locale data.

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    )annotationsN)abc)IteratorMappingMutableMapping)	lru_cache)chain)Anydict[str, Any]_cachezlocale-dataz%^(con|prn|aux|nul|com[0-9]|lpt[0-9])$namestrreturn
str | Nonec                   | rt          | t                    sdS |                                                                 } t	          j        t          t                      g          D ]}| |                                k    r|c S dS )zNormalize a locale ID by stripping spaces and apply proper casing.

    Returns the normalized locale ID string or `None` if the ID is not
    recognized.
    N)
isinstancer   striplowerr	   from_iterabler   locale_identifiers)r   	locale_ids     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/babel/localedata.pynormalize_localer   !   s      z$,, t::<<D(&2D2F2F)GHH  	9??$$$$ %     os.PathLike[str] | strc                P   t           j                            |           } t          j        dk    rPt
                              t           j                            |           d                   rt          d|  d          t           j        	                    t          |  d          S )z?
    Resolve a locale identifier to a `.dat` path on disk.
    win32r   zName z is invalid on Windows.dat)ospathbasenamesysplatform_windows_reserved_name_rematchsplitext
ValueErrorjoin_dirname)r   s    r   resolve_locale_filenamer*   /   s     7D!!D |w#<#B#B27CSCSTXCYCYZ[C\#]#]====>>> 7<<T---000r   boolc                    | rt          | t                    sdS | t          v rdS t          j                            t          |                     }|rdnt          t          |                     S )zCheck whether locale data is available for the given locale.

    Returns `True` if it exists, `False` otherwise.

    :param name: the locale identifier string
    FT)	r   r   r   r   r    existsr*   r+   r   )r   
file_founds     r   r-   r-   ?   sl      z$,, uv~~t 7 = =>>J?444(8(>(>#?#??r   )maxsize	list[str]c                 \    d d t          j        t                    D             D             S )a&  Return a list of all locale identifiers for which locale data is
    available.

    This data is cached after the first invocation.
    You can clear the cache by calling `locale_identifiers.cache_clear()`.

    .. versionadded:: 0.8.1

    :return: a list of locale identifiers (strings)
    c                0    g | ]\  }}|d k    |dk    |S )r   root ).0stem	extensions      r   
<listcomp>z&locale_identifiers.<locals>.<listcomp>Z   s9       D)46>> 	 $2>>r   c              3  T   K   | ]#}t           j                            |          V  $d S N)r   r    r&   )r5   filenames     r   	<genexpr>z%locale_identifiers.<locals>.<genexpr>]   s2      II		(	#	#IIIIIIr   )r   listdirr)   r4   r   r   r   r   N   s>      	JIBJx4H4HIII   r   c                    ddl m}m} 	  ||           ^}}}}}n# t          $ r Y dS w xY w|r;|r9|s7|s5|s3 |d                              |          } ||          ^}	}	}
}	||
k    S dS )a  Return whether the locale is of the form ``lang_Script``,
    and the script is not the likely script for the language.

    This implements the behavior of the ``nonlikelyScript`` value of the
    ``localRules`` attribute for parent locales added in CLDR 45.
    r   )
get_globalparse_localeFlikely_subtags)
babel.corer?   r@   r'   get)r   r?   r@   lang	territoryscriptvariantrestlikely_subtag_likely_scripts              r   _is_non_likely_scriptrL   b   s     433333332>,t2D2D/i44   uu  ' 'y ' ' '"
#34488>>".,}"="=1ma&&5s    
))Tmerge_inheritedc                v   t           j                            |           } t                                           	 t
                              |           }|s+| dk    s|si }nddlm}  |d                              |           }|sYt          |           rd}nG| 
                    d          }t          |          dk    rdnd                    |dd                   }t          |                                          }t          |           }t!          |d	          5 }| dk    r%|r#t#          |t%          j        |                     nt%          j        |          }ddd           n# 1 swxY w Y   |t
          | <   |t                                           S # t                                           w xY w)
af  Load the locale data for the given locale.

    The locale data is a dictionary that contains much of the data defined by
    the Common Locale Data Repository (CLDR). This data is stored as a
    collection of pickle files inside the ``babel`` package.

    >>> d = load('en_US')
    >>> d['languages']['sv']
    u'Swedish'

    Note that the results are cached, and subsequent requests for the same
    locale return the same dictionary:

    >>> d1 = load('en_US')
    >>> d2 = load('en_US')
    >>> d1 is d2
    True

    :param name: the locale identifier string (or "root")
    :param merge_inherited: whether the inherited data should be merged into
                            the data of the requested locale
    :raise `IOError`: if no locale data file is found for the given locale
                      identifier, or one of the locales it inherits from
    r3   r   )r?   parent_exceptionsrJ      Nrb)r   r    r!   _cache_lockacquirer   rC   rB   r?   rL   splitlenr(   loadcopyr*   openmergepicklerelease)r   rM   datar?   parentpartsr;   fileobjs           r   rW   rW   w   s   2 7D!!Dzz$ 	 v~~_~111111#$788<<TBB U,T22 U!' $

3+.u::??sPRs@T@TF||((**.t44Hh%% 06>>o>$G 4 45555!;w//D	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  F4Ls1   C'F !A E-!F -E11F 4E15F F8dict1MutableMapping[Any, Any]dict2Mapping[Any, Any]Nonec                   |                                 D ]\  }}||                     |          }t          |t                    r|i }t          |t                    r||f}njt          |t
                    r.|\  }}|                                }t          ||           ||f}n'|                                }t          ||           n|}|| |<   dS )an  Merge the data from `dict2` into the `dict1` dictionary, making copies
    of nested dictionaries.

    >>> d = {1: 'foo', 3: 'baz'}
    >>> merge(d, {1: 'Foo', 2: 'Bar'})
    >>> sorted(d.items())
    [(1, 'Foo'), (2, 'Bar'), (3, 'baz')]

    :param dict1: the dictionary to merge into
    :param dict2: the dictionary containing the data that should be merged
    N)itemsrC   r   dictAliastuplerX   rZ   )ra   rc   keyval2val1aliasotherss          r   rZ   rZ      s     [[]]  	T99S>>D$%% <DdE** 	& $<DDe,, &$(ME6#[[]]F&$'''!6?DD99;;D$%%%%E#J% r   c                  *    e Zd ZdZddZddZddZdS )ri   zRepresentation of an alias in the locale data.

    An alias is a value that refers to some other part of the locale data,
    as specified by the `keys`.
    keystuple[str, ...]r   re   c                .    t          |          | _        d S r:   )rj   rq   )selfrq   s     r   __init__zAlias.__init__   s    $KK			r   r   c                B    dt          |           j         d| j        dS )N< >)type__name__rq   rt   s    r   __repr__zAlias.__repr__   s&    74::&777777r   r]   Mapping[str | int | None, Any]c                    |}| j         D ]
}||         }t          |t                    r|                    |          }n/t          |t                    r|\  }}|                    |          }|S )zResolve the alias based on the given data.

        This is done recursively, so if one alias resolves to a second alias,
        that second alias will also be resolved.

        :param data: the locale data
        :type data: `dict`
        )rq   r   ri   resolverj   )rt   r]   baserk   rn   ro   s         r   r   zAlias.resolve   s{     9 	 	C9DDdE"" 	'<<%%DDe$$ 	' ME6==&&Dr   N)rq   rr   r   re   )r   r   )r]   r~   r   r~   )r{   
__module____qualname____doc__ru   r}   r   r4   r   r   ri   ri      sZ                8 8 8 8     r   ri   c                  L    e Zd ZdZdddZdd
ZddZddZddZddZ	ddZ
dS )LocaleDataDictzUDictionary wrapper that automatically resolves aliases to the actual
    values.
    Nr]   %MutableMapping[str | int | None, Any]r   %Mapping[str | int | None, Any] | Nonec                *    || _         ||}|| _        d S r:   )_datar   )rt   r]   r   s      r   ru   zLocaleDataDict.__init__   s    
<D			r   r   intc                *    t          | j                  S r:   )rV   r   r|   s    r   __len__zLocaleDataDict.__len__   s    4:r   Iterator[str | int | None]c                *    t          | j                  S r:   )iterr   r|   s    r   __iter__zLocaleDataDict.__iter__   s    DJr   rk   str | int | Noner
   c                   | j         |         x}}t          |t                    r|                    | j                  }t          |t
                    rA|\  }}|                    | j                                                  }t          ||           t          |t                    rt          || j                  }||ur
|| j         |<   |S N)r   )
r   r   ri   r   r   rj   rX   rZ   rh   r   )rt   rk   origvalrn   ro   s         r   __getitem__zLocaleDataDict.__getitem__  s    Z_$sc5!! 	)++di((Cc5!! 	ME6--	**//11C#vc4   	6 49555Cd??!DJsO
r   valuere   c                    || j         |<   d S r:   r   )rt   rk   r   s      r   __setitem__zLocaleDataDict.__setitem__  s    
3r   c                    | j         |= d S r:   r   )rt   rk   s     r   __delitem__zLocaleDataDict.__delitem__  s    JsOOOr   c                \    t          | j                                        | j                  S r   )r   r   rX   r   r|   s    r   rX   zLocaleDataDict.copy  s#    djoo//di@@@@r   r:   )r]   r   r   r   )r   r   )r   r   )rk   r   r   r
   )rk   r   r   r
   r   re   )rk   r   r   re   )r   r   )r{   r   r   r   ru   r   r   r   r   r   rX   r4   r   r   r   r      s                                    A A A A A Ar   r   )r   r   r   r   )r   r   r   r   )r   r   r   r+   )r   r0   )T)r   r   rM   r+   r   r   )ra   rb   rc   rd   r   re   ))r   
__future__r   r   r[   rer"   	threadingcollectionsr   collections.abcr   r   r   	functoolsr   	itertoolsr	   typingr
   r   __annotations__RLockrS   r    r(   dirname__file__r)   compileIr$   r   r*   r-   r   rL   rW   rZ   ri   r   r4   r   r   <module>r      s5     # " " " " " 				  				 



           = = = = = = = = = =                      io7<<11=AA&BJ'NPRPTUU    1 1 1 1 @ @ @ @ 4   &   *4 4 4 4 4n   B       B&A &A &A &A &AS' &A &A &A &A &Ar   