f _@sddlZddlZdddZddZddZdd Zejejd d dd Z e fd d Z [ ddZ Gddde Z daedS)NcCs|}|durZt|ttfr6tddt|d|tttjj |sTt t ||}n.tj dd}|durzt|}nttd}t|adS)Nz!tzpaths must be a list or tuple, znot z: Z PYTHONTZPATHTZPATH) isinstancestrbytes TypeErrortypeallmapospathisabs ValueError_get_invalid_paths_messageenvironget_parse_python_tzpath sysconfigZget_config_vartupler)totzpathsZ base_tzpathenv_varr)/usr/lib64/python3.10/zoneinfo/_tzpath.py reset_tzpaths$  rcCsZ|sdS|tj}tttjj|}t|t|krVddl}t |}| d|t |S)Nrrz=Invalid paths specified in PYTHONTZPATH environment variable.) splitr pathseprfilterr r lenwarningsrwarnInvalidTZPathWarning)rZ raw_tzpathZ new_tzpathrmsgrrrrs rcCs(dd|D}d}|||}d|S)Ncss|]}tj|s|VqdS)N)r r r ).0r rrr 6z-_get_invalid_paths_message..z z@Paths should be absolute but found the following relative paths:)join)rZ invalid_pathsprefixZ indented_strrrrr5srcCs6t|tD]$}tj||}tj|r |SdS)z,Retrieve the path to a TZif file from a key.N)_validate_tzfile_pathrr r r%isfile)key search_pathfilepathrrr find_tzfileAs  r,_cCsvtj|rtd|tj|}t|t|krDtd|tjtj||}||srtd|dS)Nz.ZoneInfo keys may not be absolute paths, got: z6ZoneInfo keys must be normalized relative paths, got: z;ZoneInfo keys must refer to subdirectories of TZPATH, got: )r r r r normpathrr% startswith)r _basenew_pathZresolvedrrrr'Os   r'c CsXddlm}t}zP|dd0}|D]}|}|r&||q&Wdn1sV0YWnttfyxYn0dd}tD]}t j |sqt |D]\}}}||krd|vr| dd |vr| d |D]^} t j || } t j j| |d } t jd kr| t jd } | r| |vr(q|| r|| qqqd |vrT| d |S) a"Returns a set containing all available time zones. .. caution:: This may attempt to open a large number of files, since the best way to determine if a given file on the time zone search path is to open it and check for the "magic string" at the beginning. r) resourcesZtzdataZzonesNcSsXz>t|d }|ddkWdWS1s20YWntyRYdS0dS)NrbsTZifF)openread Exception)fpathfrrr valid_keys  2 z&available_timezones..valid_keyrightposix)start/Z posixrules) importlibr3setZ open_textstripadd ImportErrorFileNotFoundErrorrr r existswalkremover%relpathsepreplace) r3Z valid_zonesr:zoner;Ztz_rootrootdirnamesfilesfiler9r)rrravailable_timezonesis@ .      rQc@seZdZdZdS)r z?Warning raised if an invalid path is specified in PYTHONTZPATH.N)__name__ __module__ __qualname____doc__rrrrr sr r)N)r rrrrr,r r/r%Z _TEST_PATHr'rQRuntimeWarningr rrrrrs    A