'VfiFdZddlmZddlmZddlZddlZddlZddlZddl m Z ddl m Z e rddl mZeejfddZejfddZddZ dd dZdS)!zx Helpers for configuring locale settings. Name `localization` is chosen to avoid overlap with builtin `locale` module. ) annotations)contextmanagerN) TYPE_CHECKING)options) Generator new_localestr | tuple[str, str]lc_varintreturn,Generator[str | tuple[str, str], None, None]c# Ktj|} tj||tj\}}| | |d|Vn|Vtj||dS#tj||wxYw)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)rr current_localenormalized_codenormalized_encodings Jc:\PYTHON\DbComparer\venv\Lib\site-packages\pandas/_config/localization.py set_localers.%f--N1,,,/5/?/A/A,,  &+>+J$<<':<< < < < <   000000000s =A,,Blcstrboolc t||5 dddn #1swxYwYdS#ttjf$rYdSwxYw)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 ValueErrorrError)rr s rcan_set_localer9s" 6 * * *                   t  %uus'.! .%.%.AAlocaleslist[str] | str normalize list[str]c4dfd|DDS)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. c0g|]}t||S)r).0locs r z"_valid_locales..es8     #        c3K|]@}r&tj|n|VAdS)N)rr!strip)r&r'r!s r z!_valid_locales..gs\  .7 GF SYY[[ ) ) )CIIKK      r)r%)rr!s `r_valid_localesr-TsG"            r)Tprefix str | NonecLtjdvrtjddg}ngS |d}g}|D]j} |t |tjj 7#t$r'|t |dYgwxYwn#t$rYnwxYw|t||Stj|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. 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) )LinuxDarwinrz-a )encodingz windows-1252Nz.* )platformsystem subprocess check_outputsplitappendrrdisplayr4 UnicodeError TypeErrorr-recompilefindalljoin)r.r! raw_localessplit_raw_locales out_localesxpatternfounds r get_localesrIos_:/// -x.>??   (--e44 " D DA D""3q7?3K#L#L#LMMMM D D D ""3q>#B#B#BCCCCC  D D      ~k9555jF''G OODIIk22 3 3E % + ++s5B5 3B?B5.B1.B50B11B55 CC)rr r r r r )rrr r r r)rr r!rr r")NT)r.r/r!rr r")__doc__ __future__r contextlibrrr6r?r8typingrpandas._config.configrcollections.abcrLC_ALLrrr-rIr%r)rrQs$ #"""""%%%%%%   ))))))*))))))5;] 1 1 1 1 1F+1-68=,=,=,=,=,=,=,r)