
    Xh#                       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j0                  j3                  ej0                  j5                  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(y) 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])$c                    | rt        | t              sy| j                         j                         } t	        j
                  t        t               g      D ]  }| |j                         k(  s|c S  y)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_iterabler   locale_identifiers)name	locale_ids     D/var/www/html/myenv/lib/python3.12/site-packages/babel/localedata.pynormalize_localer   !   s_     z$,::<D((&2D2F)GH 	9??$$    c                <   t         j                  j                  |       } t        j                  dk(  rDt
        j                  t         j                  j                  |       d         rt        d|  d      t         j                  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|     77D!D ||w#<#B#B277CSCSTXCYZ[C\#]5&<=>> 77<<TF$-00r   c                    | rt        | t              sy| t        v ryt        j                  j                  t        |             }|rdS 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)   ?   sM     z$,v~ 7 =>J4?4(8(>#??r   )maxsizec                     d t        j                  t              D        D  cg c]  \  } }|dk(  r| dk7  r|  c}} S c c}} w )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              3  Z   K   | ]#  }t         j                  j                  |       % y wN)r   r   r#   ).0filenames     r   	<genexpr>z%locale_identifiers.<locals>.<genexpr>]   s     I		(	#Is   )+r   root)r   listdirr&   )stem	extensions     r   r   r   N   sE     	JBJJx4HID)46> 	  s   >c                    ddl m}m} 	  ||       ^}}}}}|r0|r.|s,|s*|s( |d      j	                  |      } ||      ^}	}	}
}	||
k7  S y# t        $ r Y yw xY w)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.corer8   r9   r$   get)r   r8   r9   lang	territoryscriptvariantrestlikely_subtag_likely_scripts              r   _is_non_likely_scriptrE   b   sy     42>t2D/i4 y"#3488>".}"=1ma&&  s   A
 
	AAc                   t         j                  j                  |       } t        j	                          	 t
        j                  |       }|s| dk(  s|si }n{ddlm}  |d      j                  |       }|sCt        |       rd}n5| j                  d      }t        |      dk(  rdndj                  |dd       }t        |      j                         }t        |       }t!        |d	      5 }| dk7  r"|r t#        |t%        j                  |             nt%        j                  |      }ddd       |t
        | <   |t        j'                          S # 1 sw Y   (xY w# t        j'                          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   )r8   parent_exceptionsrC      Nrb)r   r   r   _cache_lockacquirer   r<   r;   r8   rE   splitlenr%   loadcopyr'   openmergepicklerelease)r   merge_inheriteddatar8   parentpartsr1   fileobjs           r   rO   rO   w   s/   2 77D!Dzz$v~_1#$78<<TB,T2!' $

3+.u:?sPR@TF|((*.t4Hh% 06>o$G 45!;;w/D	0
  F4L0 0 	s$   B3E (=E%E EE E.c                b   |j                         D ]  \  }}|	| j                  |      }t        |t              rl|i }t        |t              r||f}nUt        |t
              r&|\  }}|j                         }t        ||       ||f}n|j                         }t        ||       n|}|| |<    y)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tuplerP   rR   )dict1dict2keyval2val1aliasotherss          r   rR   rR      s     [[] 	T99S>D$%<DdE* $<De,$(ME6#[[]F&$'!6?D99;D$%E#J%r   c                  (    e Zd ZdZddZddZddZy)	r]   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        |      | _        y r/   )r^   keys)selfrh   s     r   __init__zAlias.__init__   s    $K	r   c                N    dt        |       j                   d| j                  dS )N< >)type__name__rh   ri   s    r   __repr__zAlias.__repr__   s&    4:&&'qQ77r   c                    |}| j                   D ]  }||   }	 t        |t              r|j                  |      }|S t        |t              r|\  }}|j                  |      }|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`
        )rh   r   r]   resolver^   )ri   rV   basera   rd   re   s         r   rt   zAlias.resolve   sl     99 	C9D	dE"<<%D  e$ ME6==&Dr   N)rh   ztuple[str, ...]returnNone)rv   r   )rV   Mapping[str | int | None, Any]rv   rx   )rp   
__module____qualname____doc__rj   rr   rt    r   r   r]   r]      s     8r   r]   c                  J    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
y)LocaleDataDictzUDictionary wrapper that automatically resolves aliases to the actual
    values.
    Nc                (    || _         ||}|| _        y r/   )_dataru   )ri   rV   ru   s      r   rj   zLocaleDataDict.__init__   s    
<D	r   c                ,    t        | j                        S r/   )rN   r   rq   s    r   __len__zLocaleDataDict.__len__   s    4::r   c                ,    t        | j                        S r/   )iterr   rq   s    r   __iter__zLocaleDataDict.__iter__   s    DJJr   c                   | j                   |   x}}t        |t              r|j                  | j                        }t        |t
              r:|\  }}|j                  | j                        j                         }t        ||       t        |t              rt        || j                        }||ur|| j                   |<   |S N)ru   )
r   r   r]   rt   ru   r^   rP   rR   r\   r~   )ri   ra   origvalrd   re   s         r   __getitem__zLocaleDataDict.__getitem__  s    ZZ_$sc5!++dii(Cc5!ME6--		*//1C#vc4  4995Cd?!DJJsO
r   c                "    || j                   |<   y r/   r   )ri   ra   values      r   __setitem__zLocaleDataDict.__setitem__  s    

3r   c                    | j                   |= y r/   r   )ri   ra   s     r   __delitem__zLocaleDataDict.__delitem__  s    JJsOr   c                `    t        | j                  j                         | j                        S r   )r~   r   rP   ru   rq   s    r   rP   zLocaleDataDict.copy  s    djjoo/dii@@r   r/   )rV   z%MutableMapping[str | int | None, Any]ru   z%Mapping[str | int | None, Any] | None)rv   int)rv   zIterator[str | int | None])ra   str | int | Nonerv   r
   )ra   r   r   r
   rv   rw   )ra   r   rv   rw   )rv   r~   )rp   ry   rz   r{   rj   r   r   r   r   r   rP   r|   r   r   r~   r~      s+      Ar   r~   )r   r   rv   z
str | None)r   os.PathLike[str] | strrv   r   )r   r   rv   r*   )rv   z	list[str])T)r   r   rU   r*   rv   r   )r_   zMutableMapping[Any, Any]r`   zMapping[Any, Any]rv   rw   ))r{   
__future__r   r   rS   rer   	threadingcollectionsr   collections.abcr   r   r   	functoolsr   	itertoolsr	   typingr
   r   __annotations__RLockrK   r   r%   dirname__file__r&   compileIr!   r   r'   r)   r   rE   rO   rR   r]   r~   r|   r   r   <module>r      s    # 	  	 
   = =    ioo77<<1=A&BJJ'NPRPTPTU 1 @ 4 &*4nB B&AS'' &Ar   