f _c@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)Z isinstanceZstrZbytesZ TypeErrorZtypeZallZmapospathisabs ValueError_get_invalid_paths_messageZenvironZget_parse_python_tzpath sysconfigZget_config_vartupler)ZtotzpathsZ base_tzpathenv_varr )/usr/lib64/python3.10/zoneinfo/_tzpath.py reset_tzpaths$  rcCsZ|sdS|tj}tttjj|}t|t|krVddl}t |}| d|t |S)Nr rz=Invalid paths specified in PYTHONTZPATH environment variable.) ZsplitrZpathsepr ZfilterrrlenwarningsrZwarnInvalidTZPathWarning)r Z raw_tzpathZ new_tzpathrZmsgr r r rs rcCs(dd|D}d}|||}d|S)Ncss|]}tj|s|VqdSN)rrr)Z.0rr r r Z 6sz-_get_invalid_paths_message..z z@Paths should be absolute but found the following relative paths:)join)r Z invalid_pathsZprefixZ indented_strr r r r5srcCs6t|tD]$}tj||}tj|r |SdS)z,Retrieve the path to a TZif file from a key.N)_validate_tzfile_pathrrrrZisfile)keyZ search_pathZfilepathr r r find_tzfileAs  rZ_icCsvtj|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: )rrrrnormpathrrZ startswith)rZ_baseZnew_pathZresolvedr r r rOs   rc 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)NZrbisTZifF)ZopenZreadZ Exception)fpathfr r r valid_keys  2 z&available_timezones..valid_keyZrightZposix)Zstartz/Z posixrules)Z importlibrZsetZ open_textZstripZaddZ ImportErrorZFileNotFoundErrorrrrZexistsZwalkZremoverZrelpathZsepZreplace) rZ valid_zonesrZzonerZtz_rootZrootZdirnamesZfilesZfilerrr r r available_timezonesis@ .      rc@seZdZdZdS)rz?Warning raised if an invalid path is specified in PYTHONTZPATH.N)Z__name__Z __module__Z __qualname__Z__doc__r r r r rsrr r)rrrrrrrrrZ _TEST_PATHrrZRuntimeWarningrrr r r r Zs    A