84yddlZddlZddlmZddlmZddlmZddlm Z ej drddlm Z nd e fd Z Gd d e Zd ed eefdZd gZdS)N) ConfigParser)Path)Optional)PlatformDirsABClinux)getuidreturnc td)Nzshould only be used on Linux) RuntimeError/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/platformdirs/unix.pyr r s9:::rcfeZdZdZedefdZedefdZdedefdZedefdZ edefdZ edefd Z edefd Z edefd Z edefd Zedefd ZedefdZedefdZdedefdZdS)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 `. r ctjdd}|stjd}||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_versionselfrs r user_data_dirzUnix.user_data_dirsS z~~or22zz|| 87%%&677D00666rctjdd}|sdtjd}||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_pathrs r site_data_dirzUnix.site_data_dir(sOz~~or22zz|| =z)Unix._with_multi_path..9s8aaaRST66rw7I7I!7L7LMMaaar)splitrr" multipathjoin)rr path_lists` rr#zUnix._with_multi_path5s[JJrz** ~ '!!A#IaaaaW`aaa zy)))rctjdd}|stjd}||S)z :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or ``$XDG_CONFIG_HOME/$appname/$version`` XDG_CONFIG_HOMErz ~/.configrrs ruser_config_dirzUnix.user_config_dir<sS z~~/44zz|| 37%%k22D00666rctjdd}|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#rs rsite_config_dirzUnix.site_config_dirGsCz~~/44zz|| D$$T***rctjdd}|stjd}||S)z :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or ``~/$XDG_CACHE_HOME/$appname/$version`` XDG_CACHE_HOMErz~/.cacherrs ruser_cache_dirzUnix.user_cache_dirTsS z~~.33zz|| 27%%j11D00666rctjdd}|stjd}||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/staterrs ruser_state_dirzUnix.user_state_dir_sT z~~.33zz|| 87%%&677D00666rcb|j}|jr tj|d}|S)zx :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it log)r6opinionrrr,rs r user_log_dirzUnix.user_log_dirjs0 " < -7<<e,,D rctd}|Stjdd}|stjd}|S)zU :return: documents directory tied to the user, e.g. ``~/Documents`` XDG_DOCUMENTS_DIRNrz ~/Documents)_get_user_dirs_folderrrrrrr)r documents_dirs ruser_documents_dirzUnix.user_documents_dirts^ ..ABB  JNN+>CCIIKKM  B " 2 2= A A rctjdd}|sdt }||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/)rrrrr rrs ruser_runtime_dirzUnix.user_runtime_dirsO z~~/44zz|| +***D00666rc6||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$rs rsite_data_pathzUnix.site_data_paths44T5GHHHrc6||jS)zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)rGr3rHs rsite_config_pathzUnix.site_config_paths44T5IJJJr directorycx|jr%|tjd}t |S)Nr)r+r*rr"r)rrLs rrGz%Unix._first_item_as_path_if_multipaths0 > 7! 33A6IIrN)__name__ __module__ __qualname____doc__propertystrrr$r#r0r3r6r9r=rBrErrIrKrGr rrrrs  7s777X7 +s + + +X +*S*S****7777X7 + + + +X +7777X77777X7cX C   X 7#777X7IIIIXIK$KKKXK#$rrkeyc(tjtjd}tj|rt }t|5}|d| dddn #1swxYwY||dvrdS|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] Ntop"z$HOME~) rrr,rr0existsropen read_stringreadrreplacer)rTuser_dirs_config_pathparserstreamrs rr@r@s%GLL)?AQRR w~~+,,  ' ( ( :F   888 9 9 9 : : : : : : : : : : : : : : : fUm # #4e}S!'',,||GRW%7%7%<%<== 4s.+B%%B),B))rsys configparserrpathlibrtypingrapirplatform startswithr intrrSr@__all__r rrrjs %%%%%% <7##;;C;;;;IIIII?IIIXsx},  r