zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
U
¬ý°d®ã@s²dZddlmZddlmZddlZddlZddlZddlZddl    m
Z
ddl m Z eej fddd    d
œd d „ƒZej fd dddœdd„Zddddœdd„Zdddddœdd„ZdS)zx
Helpers for configuring locale settings.
 
Name `localization` is chosen to avoid overlap with builtin `locale` module.
é)Ú annotations)ÚcontextmanagerN)Ú    Generator)Úoptionszstr | tuple[str, str]Úintz,Generator[str | tuple[str, str], None, None])Ú
new_localeÚlc_varÚreturnc
csbt |¡}zDt ||¡t ¡\}}|dk    rF|dk    rF|›d|›Vn|VW5t ||¡XdS)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)rrZcurrent_localeZnormalized_codeZnormalized_encoding©rúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/_config/localization.pyÚ
set_locales
 
rÚstrÚbool)Úlcrr    c    CsBzt||dW5QRXWnttjfk
r8YdSXdSdS)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
    )rFTN)rÚ
ValueErrorr ÚError)rrrrrÚcan_set_locale6s rzlist[str] | strz    list[str])ÚlocalesÚ    normalizer    csdd„‡fdd„|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.
    cSsg|]}t|ƒr|‘qSr)r©Ú.0ÚlocrrrÚ
<listcomp>bsûz"_valid_locales.<locals>.<listcomp>c3s(|] }ˆrt | ¡¡n| ¡VqdS)N)r rÚstripr©rrrÚ    <genexpr>dsÿz!_valid_locales.<locals>.<genexpr>r)rrrrrÚ_valid_localesQs
 
þþr Tz
str | None)Úprefixrr    c
CsÐt ¡dkrt ddg¡}ngSz^| d¡}g}|D]F}z| t|tjj    d¡Wq4t
k
rx| t|dd¡Yq4Xq4Wnt k
r’YnX|dkr¦t ||ƒSt  |›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)
 
    )ÚLinuxÚDarwinr z-aó
)Úencodingz windows-1252Nz.*Ú
)ÚplatformÚsystemÚ
subprocessÚ check_outputÚsplitÚappendrrZdisplayr%Ú UnicodeErrorÚ    TypeErrorr ÚreÚcompileÚfindallÚjoin)r!rZ raw_localesZsplit_raw_localesZ out_localesÚxÚpatternÚfoundrrrÚ get_localesls$ 
 
r6)NT)Ú__doc__Ú
__future__rÚ
contextlibrr r'r/r)ÚtypingrZpandas._config.configrÚLC_ALLrrr r6rrrrÚ<module>s     ÿ#þ