gL iFdZddlmZddlmZddlZddlZddlZddlZddl m Z ddl m Z e rddl mZeejf d dZejfd d Zdd Z d dd Zy)zx Helpers for configuring locale settings. Name `localization` is chosen to avoid overlap with builtin `locale` module. ) annotations)contextmanagerN) TYPE_CHECKING)options) Generatorc#Ktj|} tj||tj\}}| | |d|n|tj||y#tj||wxYww)aE Context manager for temporarily setting a locale. Parameters ---------- new_locale : str or tuple A string of the form .. 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) new_localelc_varcurrent_localenormalized_codenormalized_encodings a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/_config/localization.py set_localers.%%f-N1,/5/?/?/A,,  &+>+J$%Q':&;< < 00sB ?A/B /BB c t||5 dddy#1swYyxYw#ttjf$rYywxYw)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 )rNTF)r ValueErrorr Error)lcrs rcan_set_localer9sJ" 6 *         %s# &&#&&AAcVfd|DDcgc]}t|r|c}Scc}w)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. c3K|]9}r#tj|jn|j;yw)N)r normalizestrip).0locrs r z!_valid_locales..gs7 .7F  SYY[ )CIIK G s?A)r)localesrrs ` r_valid_localesr!Ts7&     #    s&ctjdvrtjddg}ngS |j d}g}|D]7} |j t |tjj9 | t|Stj|d}|jdj!}t||S#t$r|j t |dYwxYw#t$rYwxYw) 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. 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 an empty list (no locale available, e.g. Windows) )LinuxDarwinr z-a )encodingz windows-1252z.* )platformsystem subprocess check_outputsplitappendstrrdisplayr& UnicodeError TypeErrorr!recompilefindalljoin)prefixr raw_localessplit_raw_locales out_localesxpatternfounds r get_localesr=os :// --x.>?   (--e4 " DA D""3q7??3K3K#LM D~k955jjF82'G OODIIk2 3E % ++!  D ""3q>#BC  D    s5C? 4C?C?%C<9C?;C<<C?? D  D )r zstr | tuple[str, str]rintreturnz,Generator[str | tuple[str, str], None, None])rr.rr>r?bool)r zlist[str] | strrr@r? list[str])NT)r6z str | Nonerr@r?rA)__doc__ __future__r contextlibrr r(r2r*typingrpandas._config.configrcollections.abcrLC_ALLrrr!r=rrKs #%   ))5;]] 1% 1/2 11 1 1F+1--68=, =,=,=,rJ