
    Wh                        d Z ddlmZ ddlmZ ddlZddlZddlZddlm	Z	m
Z
 ddlmZ eej        fd d            Zej        fd!dZd"dZd#dZddefd$dZdS )%zx
Helpers for configuring locale settings.

Name `localization` is chosen to avoid overlap with builtin `locale` module.
    )annotations)contextmanagerN)CallableIterator)options
new_localestr | tuple[str, str]lc_varintreturnIterator[str | tuple[str, str]]c              #    K   t          j        |          }	 t          j        ||            t          j                    \  }}||
| d| V  n| V  t          j        ||           dS # t          j        ||           w xY w)aE  
    Context manager for temporarily setting a locale.

    Parameters
    ----------
    new_locale : str or tuple
        A string of the form <language_country>.<encoding>. For example to set
        the current locale to US English with a UTF8 encoding, you would pass
        "en_US.UTF-8".
    lc_var : int, default `locale.LC_ALL`
        The category of the locale being set.

    Notes
    -----
    This is useful when you want to run a particular block of code under a
    particular locale, without globally setting the locale. This probably isn't
    thread-safe.
    N.)locale	setlocale	getlocale)r   r
   current_localenormalized_codenormalized_encodings        a/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pandas/_config/localization.py
set_localer      s      . %f--N1,,,/5/?/A/A,,&+>+J$<<':<<<<<<000000000s   =A, ,Blcstrboolc                    	 t          | |          5  	 ddd           n# 1 swxY w Y   dS # t          t          j        f$ r Y dS w xY w)aj  
    Check to see if we can set a locale, and subsequently get the locale,
    without raising an Exception.

    Parameters
    ----------
    lc : str
        The locale to attempt to set.
    lc_var : int, default `locale.LC_ALL`
        The category of the locale being set.

    Returns
    -------
    bool
        Whether the passed locale can be set
    )r
   NTF)r   
ValueErrorr   Error)r   r
   s     r   can_set_localer   8   s    "6*** 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 t	 %   uus'   . !. %. %. AAlocaleslist[str] | str	normalize	list[str]c                4    d fd| D             D             S )ar  
    Return a list of normalized locales that do not throw an ``Exception``
    when set.

    Parameters
    ----------
    locales : str
        A string where each locale is separated by a newline.
    normalize : bool
        Whether to call ``locale.normalize`` on each locale.

    Returns
    -------
    valid_locales : list
        A list of valid locales.
    c                0    g | ]}t          |          |S  )r   ).0locs     r   
<listcomp>z"_valid_locales.<locals>.<listcomp>d   s8        #      c              3     K   | ]@}r&t          j        |                                          n|                                V  Ad S )N)r   r!   strip)r&   r'   r!   s     r   	<genexpr>z!_valid_locales.<locals>.<genexpr>f   s\       
 
 .7GFSYY[[)))CIIKK
 
 
 
 
 
r)   r%   )r   r!   s    `r   _valid_localesr-   S   sG    " 
 
 
 

 
 
   r)   bytesc                 0    t          j        dgd          S )Nz	locale -aT)shell)
subprocesscheck_outputr%   r)   r   _default_locale_getterr3   n   s    "K=====r)   Tprefix
str | Nonelocale_getterCallable[[], bytes]list[str] | Nonec                4   	  |            }n# t           j        $ r Y dS w xY w	 |                    d          }g }|D ]j}	 |                    t	          |t
          j        j                             7# t          $ r' |                    t	          |d                     Y gw xY wn# t          $ r Y nw xY w| t          ||          S t          j        |  d          }|                    d                    |                    }t          ||          S )a  
    Get all the locales that are available on the system.

    Parameters
    ----------
    prefix : str
        If not ``None`` then return only those locales with the prefix
        provided. For example to get all English language locales (those that
        start with ``"en"``), pass ``prefix="en"``.
    normalize : bool
        Call ``locale.normalize`` on the resulting list of available locales.
        If ``True``, only locales that can be set without throwing an
        ``Exception`` are returned.
    locale_getter : callable
        The function to use to retrieve the current locales. This should return
        a string with each locale separated by a newline character.

    Returns
    -------
    locales : list of strings
        A list of locale strings that can be set with ``locale.setlocale()``.
        For example::

            locale.setlocale(locale.LC_ALL, locale_string)

    On error will return None (no locale available, e.g. Windows)

    N   
)encodingzwindows-1252z.*
)r1   CalledProcessErrorsplitappendr   r   displayr;   UnicodeError	TypeErrorr-   recompilefindalljoin)	r4   r!   r6   raw_localessplit_raw_localesout_localesxpatternfounds	            r   get_localesrM   r   se   B#moo(    tt
 (--e44" 		D 		DAD""3q7?3K#L#L#LMMMM D D D ""3q>#B#B#BCCCCCD		D     ~k9555jF''GOODIIk2233E%+++sA   
   B)  3A43B) 4.B%"B) $B%%B) )
B65B6)r   r	   r
   r   r   r   )r   r   r
   r   r   r   )r   r    r!   r   r   r"   )r   r.   )r4   r5   r!   r   r6   r7   r   r8   )__doc__
__future__r   
contextlibr   r   rC   r1   typingr   r   pandas._config.configr   LC_ALLr   r   r-   r3   rM   r%   r)   r   <module>rT      s7   
 # " " " " " % % % % % %  				           
 * ) ) ) ) ) 5;] 1  1  1  1  1F +1-     6   6> > > >
 )?A, A, A, A, A, A, A,r)   