K i(dZddlmZddlZddlZddlmZddlmZddl m Z m Z ddl m Z e rdd lmZej d k(rdd Zndd lmZGd de ZddZddZdgZy)zUnix.) annotationsN) ConfigParser)Path) TYPE_CHECKINGNoReturn)PlatformDirsABC)Iteratorwin32cd}t|)Nzshould only be used on Unix) RuntimeError)msgs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/platformdirs/unix.pygetuidrs+3)rceZdZdZeddZeddZeddZeddZeddZ eddZ eddZ edd Z edd Z edd Zedd Zedd ZeddZeddZeddZeddZeddZeddZeddZeddZeddZddZddZy)Unixa On Unix/Linux, we follow the `XDG Basedir Spec `_. The spec allows overriding directories with environment variables. The examples shown are the default values, alongside the name of the environment variable that overrides them. Makes use of the `appname `, `version `, `multipath `, `opinion `, `ensure_exists `. ctjjdd}|jstjj d}|j |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_dir'sG zz~~or2zz|77%%&67D0066rc tjjdd}|jsdtjd}|j tjDcgc]}|j |c}Scc}w)N XDG_DATA_DIRSrz/usr/local/sharez /usr/share)rrrrpathsepsplitrr rps r_site_data_dirszUnix._site_data_dirs2s]zz~~or2zz|%bjj\Bjj>TU11!4UUUs&Bcz|j}|js|dStjj |S)aZ :return: data directories shared by users (if `multipath ` is enabled and ``XDG_DATA_DIRS`` 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`` r)r( multipathrr$joinr dirss r site_data_dirzUnix.site_data_dir9s2##~~7Nzzt$$rctjjdd}|jstjj d}|j |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_dirFsG zz~~/4zz|77%%k2D0066rctjjdd}|jsd}|j tj Dcgc]}|j |c}Scc}w)NXDG_CONFIG_DIRSrz/etc/xdg)rrrrr%r$rr&s r_site_config_dirszUnix._site_config_dirsQsQzz~~/4zz|D>Bjj>TU11!4UUUsA/cz|j}|js|dStjj |S)a2 :return: config directories shared by users (if `multipath ` is enabled and ``XDG_CONFIG_DIRS`` 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`` r)r4r*rr$r+r,s rsite_config_dirzUnix.site_config_dirXs2%%~~7Nzzt$$rctjjdd}|jstjj d}|j |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_diresG zz~~.3zz|77%%j1D0066rc$|jdS)zO:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z /var/cache)rr s rsite_cache_dirzUnix.site_cache_dirps00>>rctjjdd}|jstjj d}|j |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_dirusH zz~~.3zz|77%%&67D0066rc|j}|jr1tjj |d}|j ||S)zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itlog)r?opinionrrr+_optionally_create_directoryrs r user_log_dirzUnix.user_log_dirs="" <<77<<e,D  - -d 3 rctddS)zC:return: documents directory tied to the user, e.g. ``~/Documents``XDG_DOCUMENTS_DIRz ~/Documents_get_user_media_dirr;s ruser_documents_dirzUnix.user_documents_dirs##6 FFrctddS)zC:return: downloads directory tied to the user, e.g. ``~/Downloads``XDG_DOWNLOAD_DIRz ~/DownloadsrGr;s ruser_downloads_dirzUnix.user_downloads_dirs##5}EErctddS)zA:return: pictures directory tied to the user, e.g. ``~/Pictures``XDG_PICTURES_DIRz ~/PicturesrGr;s ruser_pictures_dirzUnix.user_pictures_dirs##5|DDrctddS)z=:return: videos directory tied to the user, e.g. ``~/Videos``XDG_VIDEOS_DIRz~/VideosrGr;s ruser_videos_dirzUnix.user_videos_dirs##3Z@@rctddS)z;:return: music directory tied to the user, e.g. ``~/Music`` XDG_MUSIC_DIRz~/MusicrGr;s ruser_music_dirzUnix.user_music_dirs#?I>>rctddS)z?:return: desktop directory tied to the user, e.g. ``~/Desktop``XDG_DESKTOP_DIRz ~/DesktoprGr;s ruser_desktop_dirzUnix.user_desktop_dirs##4kBBrcDtjjdd}|js`tj j dr4dt}t|jsdt}n dt}|j|S)az :return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version``. For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/user/$(id -u)/$appname/$version`` if exists, otherwise ``/tmp/runtime-$(id -u)/$appname/$version``, if``$XDG_RUNTIME_DIR`` is not set. XDG_RUNTIME_DIRrfreebsdopenbsdnetbsdz/var/run/user/z /tmp/runtime-z /run/user/) rrrrsysplatform startswithrrexistsrrs ruser_runtime_dirzUnix.user_runtime_dirszz~~/4zz|||&&'GH'z2Dz((**68*5D#FH:.0066rctjjdd}|js$tj j drd}nd}|j|S)am :return: runtime directory shared by users, e.g. ``/run/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version``. Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will fall back to paths associated to the root user instead of a regular logged-in user if it's not set. If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir` instead. For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/$appname/$version`` if ``$XDG_RUNTIME_DIR`` is not set. rZrr[z/var/runz/run)rrrrr_r`rarrs rsite_runtime_dirzUnix.site_runtime_dirsPzz~~/4zz|||&&'GH!0066rc8|j|jS)zh:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``) _first_item_as_path_if_multipathr.r;s rsite_data_pathzUnix.site_data_paths44T5G5GHHrc8|j|jS)zj:return: config path shared by the users, returns the first item, even if ``multipath`` is set to ``True``)rgr6r;s rsite_config_pathzUnix.site_config_paths44T5I5IJJrc8|j|jS)zi:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)rgr<r;s rsite_cache_pathzUnix.site_cache_paths44T5H5HIIrc#TK|j|jEd{y7w)z4:yield: all user and site configuration directories.N)r1r4r;s riter_config_dirszUnix.iter_config_dirss!""")))) (&(c#TK|j|jEd{y7w)z+:yield: all user and site data directories.N)r!r(r;s riter_data_dirszUnix.iter_data_dirss!   ''''roN)returnstr)rrz list[str])rrr)rrz Iterator[str])__name__ __module__ __qualname____doc__propertyr!r(r.r1r4r6r9r<r?rDrIrLrOrRrUrXrcrerhrjrlrnrqrrrrs 77VV  % %77VV  % %77??77GGFFEEAA??CC77&77*IIKKJJ* (rrct|}|Otjj|dj }|stj j |}|S)Nr)_get_user_dirs_folderrrrrrr)env_varfallback_tilde_path media_dirs rrHrHsM%g.IJJNN7B/557 **+>?I rcttjdz }|jrt }|j 5}|j d|jddd||dvry|d|jd}|jdtjjdSy#1swYXxYw)z{ Return directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/. zuser-dirs.dirsz[top] Ntop"z$HOME~) rrr1rbropen read_stringreadrreplacerrr)keyuser_dirs_config_pathparserstreamrs rr{r{s!!7!78;KK##% " ' ' ) :V   8 9 : fUm #e}S!'',||GRWW%7%7%<==  : :s #CC)rrr)r|rsr}rsrrrs)rrsrrz str | None)rw __future__rrr_ configparserrpathlibrtypingrrapir collections.abcr r`rrrHr{__all__ryrrrs^ " %* (<<7 N(?N(b4  r