idddlmZddlZddlZddlmZddlmZddlm Z ej drddlm Z ndd Z Gd d e Z ddZd gZdS)) annotationsN) ConfigParser)Path)PlatformDirsABClinux)getuidreturnintc td)Nzshould only be used on Linux) RuntimeErrorF/opt/cloudlinux/venv/lib/python3.11/site-packages/platformdirs/unix.pyr r s9:::rc*eZdZdZeddZeddZddZeddZedd Z edd Z edd Z edd Z edd Z eddZeddZeddZddZdS)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 strctjdd}|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..:s8aaaRST66rw7I7I!7L7LMMaaar)splitrr$ multipathjoin)r r path_lists` rr%zUnix._with_multi_path6s[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_dirHsCz~~/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_dirUsS 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)zy :return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it log)r;opinionrrr.rs r user_log_dirzUnix.user_log_dirks0 " < -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_dirus^ ..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|| +***D00666rrc6||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 s 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``)rIr5rJs rsite_config_pathzUnix.site_config_paths44T5IJJJr directorycx|jr%|tjd}t |S)Nr)r-r,rr$r)r rNs rrIz%Unix._first_item_as_path_if_multipaths0 > 7! 33A6IIrN)r r)rrr r)r r)rNrr r)__name__ __module__ __qualname____doc__propertyr!r&r%r2r5r8r;r?rDrGrKrMrIrrrrrs  777X7 + + +X +****777X7 + + +X +777X7777X7X   X 777X7IIIXIKKKXKrrkeyr str | Nonec(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.rr2existsropen read_stringreadrreplacer)rUuser_dirs_config_pathparserstreamrs rrBrBs%GLL)?AQRR w~~+,,  ' ( ( :F   888 9 9 9 : : : : : : : : : : : : : : : fUm # #4e}S!'',,||GRW%7%7%<%<== 4s.+B%%B),B))r r )rUrr rV) __future__rrsys configparserrpathlibrapirplatform startswithr rrB__all__rrrrks"""""" %%%%%% <7##;;;;;IIIII?IIIX,  r