U ʗRe@sddlmZddlZddlZddlmZddlmZddlm Z ej drZddlm Z nd d d d Z Gd dde Z dddddZdgZdS)) annotationsN) ConfigParser)Path)PlatformDirsABClinux)getuidintreturncCs tddS)Nzshould only be used on Linux) RuntimeErrorr r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/platformdirs/unix.pyrsrc@seZdZdZeddddZeddddZdddd d Zeddd d Zeddd dZ eddddZ eddddZ eddddZ eddddZ eddddZeddddZeddddZddddd Zd!S)"UnixaD On Unix/Linux, we follow the `XDG Basedir Spec `_. The spec allows overriding directories with environment variables. The examples show are the default values, alongside the name of the environment variable that overrides them. Makes use of the `appname `, `version `, `multipath `, `opinion `. strr cCs,tjdd}|s"tjd}||S)z :return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or ``$XDG_DATA_HOME/$appname/$version`` XDG_DATA_HOMEz~/.local/shareosenvirongetstrippath expanduser_append_app_name_and_versionselfrr r r user_data_dirs zUnix.user_data_dircCs.tjdd}|s$dtjd}||S)aY :return: data directories shared by users (if `multipath ` is enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version`` XDG_DATA_DIRSrz/usr/local/sharez /usr/share)rrrrpathsep_with_multi_pathrr r r site_data_dir)szUnix.site_data_dir)rr cs<|tj}js|dd}fdd|D}tj|S)Nrrcsg|]}tj|qSr )rrrr).0prr r :sz)Unix._with_multi_path..)splitrr multipathjoin)rr path_listr r$rr 6s   zUnix._with_multi_pathcCs,tjdd}|s"tjd}||S)z :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or ``$XDG_CONFIG_HOME/$appname/$version`` XDG_CONFIG_HOMErz ~/.configrrr r ruser_config_dir=s zUnix.user_config_dircCs$tjdd}|sd}||S)a/ :return: config directories shared by users (if `multipath ` is enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS path separator), e.g. ``/etc/xdg/$appname/$version`` XDG_CONFIG_DIRSrz/etc/xdg)rrrrr rr r rsite_config_dirHszUnix.site_config_dircCs,tjdd}|s"tjd}||S)z :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or ``~/$XDG_CACHE_HOME/$appname/$version`` XDG_CACHE_HOMErz~/.cacherrr r ruser_cache_dirUs zUnix.user_cache_dircCs,tjdd}|s"tjd}||S)z :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or ``$XDG_STATE_HOME/$appname/$version`` XDG_STATE_HOMErz~/.local/staterrr r ruser_state_dir`s zUnix.user_state_dircCs|j}|jrtj|d}|S)zx :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it log)r/opinionrrr(rr r r user_log_dirkszUnix.user_log_dircCs6td}|dkr2tjdd}|s2tjd}|S)zU :return: documents directory tied to the user, e.g. ``~/Documents`` XDG_DOCUMENTS_DIRNrz ~/Documents)_get_user_dirs_folderrrrrrr)r documents_dirr r ruser_documents_dirus  zUnix.user_documents_dircCs,tjdd}|s"dt}||S)z :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version`` XDG_RUNTIME_DIRrz /run/user/)rrrrrrrr r ruser_runtime_dirs zUnix.user_runtime_dirrcCs ||jS)zd:return: data path shared by users. Only return first item, even if ``multipath`` is set to ``True``) _first_item_as_path_if_multipathr!r$r r rsite_data_pathszUnix.site_data_pathcCs ||jS)zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)r;r-r$r r rsite_config_pathszUnix.site_config_path) directoryr cCs|jr|tjd}t|S)Nr)r'r&rrr)rr>r r rr;sz%Unix._first_item_as_path_if_multipathN)__name__ __module__ __qualname____doc__propertyrr!r r+r-r/r1r4r8r:r<r=r;r r r rrs2          rrz str | None)keyr c Cstjtjd}tj|rt}t|}|d| W5QRX||dkr\dS|d| d}| dtj d}|SdS)zjReturn directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/zuser-dirs.dirsz[top] topN"z$HOME~) rrr(rr+existsropen read_stringreadrreplacer)rDuser_dirs_config_pathparserstreamrr r rr6s   r6) __future__rrsys configparserrpathlibrapirplatform startswithrrr6__all__r r r rs