
    Qc                     d   d 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	 i Z
 ej                    Zej                            ej                            e          d          Z ej        dej                  Zd Zd Zd	 Zd
 ZddZ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-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    N)abc)chainzlocale-dataz%^(con|prn|aux|nul|com[0-9]|lpt[0-9])$c                    | 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)
isinstancestrstriplowerr   from_iterable_cachelocale_identifiers)name	locale_ids     0lib/python3.11/site-packages/babel/localedata.pynormalize_localer      s      z$,, t::<<D(&2D2F2F)GHH  	9??$$$ 		     c                 N   t           j                            |           } t          j        dk    rOt
                              t           j                            |           d                   rt          d| z            t           j        	                    t          d| z            S )z?
    Resolve a locale identifier to a `.dat` path on disk.
    win32r   zName %s is invalid on Windowsz%s.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 A#<#B#B27CSCSTXCYCYZ[C\#]#] A84?@@@ 7<<(T/222r   c                     | 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   boolr   )r   
file_founds     r   r!   r!   ;   so      z$,, uv~ t 7 = =>>J?444(8(>(>#?#??r   c                      t          t          dd          } | 9d d t          j        t                    D             D             xt          _        } | S )a  Return a list of all locale identifiers for which locale data is
    available.

    This data is cached after the first invocation in `locale_identifiers.cache`.

    Removing the `locale_identifiers.cache` attribute or setting it to `None`
    will cause this function to re-read the list from disk.

    .. versionadded:: 0.8.1

    :return: a list of locale identifiers (strings)
    cacheNc                 0    g | ]\  }}|d k    |dk    |S )z.datroot ).0stem	extensions      r   
<listcomp>z&locale_identifiers.<locals>.<listcomp>Y   sE     +
 +
 +
iF"	+
 (,v~	+
+
 +
 +
r   c              3   T   K   | ]#}t           j                            |          V  $d S N)r   r   r   )r)   filenames     r   	<genexpr>z%locale_identifiers.<locals>.<genexpr>\   s2      MMHRWh''MMMMMMr   )getattrr   r   listdirr   r%   )datas    r   r   r   J   si     %w55D 
+
 +
 NM
88L8LMMM+
 +
 +
 	
 4 Kr   Tc                 T   t           j                            |           } t                                           	 t
                              |           }|s| dk    s|si }nddlm}  |d                              |           }|sH| 	                    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)
ae  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
                      identifer, or one of the locales it inherits from
    r'   r   )
get_globalparent_exceptions_   Nrb)r   r   r   _cache_lockacquirer   get
babel.corer5   splitlenr   loadcopyr   openmergepicklerelease)r   merge_inheritedr3   r5   parentpartsr/   fileobjs           r   rA   rA   b   s   2 7D!!Dzz$ 	 v~ +_ +111111#$788<<TBB 6 JJsOOE5zzQ 6!'!$%*!5!5F||((**.t44Hh%% 06> 0o 0$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 E  F #E $F F'c                    |                                 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)itemsr=   r   dictAliastuplerB   rD   )dict1dict2keyval2val1aliasotherss          r   rD   rD      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 Zd Zd ZdS )rN   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`.
    c                 .    t          |          | _        d S r.   )rO   keys)selfrY   s     r   __init__zAlias.__init__   s    $KK			r   c                 B    dt          |           j        d| j        dS )N< >)type__name__rY   rZ   s    r   __repr__zAlias.__repr__   s$      JJ///;;r   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`
        )rY   r   rN   resolverO   )rZ   r3   baserR   rU   rV   s         r   re   zAlias.resolve   s{     9 	 	C9DDdE"" 	'<<%%DDe$$ 	' ME6==&&Dr   N)ra   
__module____qualname____doc__r[   rc   re   r(   r   r   rN   rN      sK              < < <    r   rN   c                   >    e Zd ZdZd
dZd Zd Zd Zd Zd Z	d	 Z
dS )LocaleDataDictzUDictionary wrapper that automatically resolves aliases to the actual
    values.
    Nc                 *    || _         ||}|| _        d S r.   )_datarf   )rZ   r3   rf   s      r   r[   zLocaleDataDict.__init__   s!    
 	D			r   c                 *    t          | j                  S r.   )r@   rm   rb   s    r   __len__zLocaleDataDict.__len__   s    4:r   c                 *    t          | j                  S r.   )iterrm   rb   s    r   __iter__zLocaleDataDict.__iter__   s    DJr   c                    | j         |         x}}t          |t                    r|                    | j                  }t          |t
                    rA|\  }}|                    | j                                                  }t          ||           t          |          t          u rt          || j                  }||ur
|| j         |<   |S N)rf   )rm   r   rN   re   rf   rO   rB   rD   r`   rM   rk   )rZ   rR   origvalrU   rV   s         r   __getitem__zLocaleDataDict.__getitem__   s    Z_$sc5!! 	)++di((Cc5!! 	ME6--	**//11C#v99 	6 49555Cd? 	"!DJsO
r   c                     || j         |<   d S r.   rm   )rZ   rR   values      r   __setitem__zLocaleDataDict.__setitem__   s    
3r   c                     | j         |= d S r.   ry   )rZ   rR   s     r   __delitem__zLocaleDataDict.__delitem__   s    JsOOOr   c                 \    t          | j                                        | j                  S rt   )rk   rm   rB   rf   rb   s    r   rB   zLocaleDataDict.copy   s#    djoo//di@@@@r   r.   )ra   rg   rh   ri   r[   ro   rr   rw   r{   r}   rB   r(   r   r   rk   rk      s                            A A A A Ar   rk   )T)ri   rE   r   rer   	threadingcollectionsr   	itertoolsr   r   RLockr;   r   r   dirname__file__r   compileIr   r   r   r!   r   rA   rD   rN   MutableMappingrk   r(   r   r   <module>r      s     				 				 



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