Ë TÞ™À DŠUãó´—dZddlmZddlZddlZddlmZddlmZddl m Z ddl m Z ejd k(rdd „Zndd lmZGd „d e «Zdd„Zdd„Zd gZy)zUnix.é)Ú annotationsN)Ú ConfigParser)ÚPath)ÚIteratoré)ÚPlatformDirsABCÚwin32có—d}t|«‚)Nzshould only be used on Unix)Ú RuntimeError)Úmsgs ú6/usr/lib/python3.12/site-packages/platformdirs/unix.pyÚgetuidrs€Ø+ˆÜ˜3ÓÐó)rcó¢—eZdZdZedd„«Zedd„«Zedd„«Zedd„«Zedd„«Z edd„«Z edd„«Z edd „«Z edd „«Z edd „«Zedd „«Zedd „«Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Zdd„Zdd„Zdd„Zy) ÚUnixaŠ 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 `, `ensure_exists `. có—tjjdd«}|j«stjj 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_HOMEÚz~/.local/share©ÚosÚenvironÚgetÚstripÚpathÚ expanduserÚ_append_app_name_and_version©Úselfrs r Ú user_data_dirzUnix.user_data_dir$sG€ô �z‰z�~‰~˜o¨rÓ2ˆØ�z‰zŒ|Ü—7‘7×%Ñ%Ð&6Ó7ˆDØ×0Ñ0°Ó6Ð6rcó —tjjdd«}|j«sdtj›d�}|j tj«D�cgc]}|j |«‘Œc}Scc}w)NÚ XDG_DATA_DIRSrz/usr/local/sharez /usr/share)rrrrÚpathsepÚsplitr©rrÚps r Ú_site_data_dirszUnix._site_data_dirs/sc€ä�z‰z�~‰~˜o¨rÓ2ˆØ�z‰zŒ|Ø%¤b§j¡j \°Ð<ˆDØ>B¿j¹jÌÏÉÔ>TÓUÑ>T¸�×1Ñ1°!Õ4Ð>TÑUÐUùÒUsÁ&Bcóz—|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"Újoin©rÚdirss r Ú site_data_dirzUnix.site_data_dir6s2€ð×#Ñ#ˆØ�~Š~ؘ‘7ˆNÜ�z‰z�‰˜tÓ$Ð$rcó—tjjdd«}|j«stjj 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 r Úuser_config_dirzUnix.user_config_dirCsG€ô �z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|Ü—7‘7×%Ñ% kÓ2ˆDØ×0Ñ0°Ó6Ð6rcóè—tjjdd«}|j«sd}|j tj «D�cgc]}|j |«‘Œc}Scc}w)NÚXDG_CONFIG_DIRSrz/etc/xdg)rrrrr#r"rr$s r Ú_site_config_dirszUnix._site_config_dirsNsW€ä�z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|؈DØ>B¿j¹jÌÏÉÔ>TÓUÑ>T¸�×1Ñ1°!Õ4Ð>TÑUÐUùÒUsÁA/cóz—|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)r2r(rr"r)r*s r Úsite_config_dirzUnix.site_config_dirUs2€ð×%Ñ%ˆØ�~Š~ؘ‘7ˆNÜ�z‰z�‰˜tÓ$Ð$rcó—tjjdd«}|j«stjj 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 r Úuser_cache_dirzUnix.user_cache_dirbsG€ô �z‰z�~‰~Ð.°Ó3ˆØ�z‰zŒ|Ü—7‘7×%Ñ% jÓ1ˆDØ×0Ñ0°Ó6Ð6rcó$—|jd«S)zO:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``z /var/cache)r©rs r Úsite_cache_dirzUnix.site_cache_dirms€ð×0Ñ0°Ó>Ð>rcó—tjjdd«}|j«stjj 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 r Úuser_state_dirzUnix.user_state_dirrsH€ô �z‰z�~‰~Ð.°Ó3ˆØ�z‰zŒ|Ü—7‘7×%Ñ%Ð&6Ó7ˆDØ×0Ñ0°Ó6Ð6rcó˜—|j}|jr1tjj |d«}|j |«|S)zg:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in itÚlog)r=Úopinionrrr)Ú_optionally_create_directoryrs r Ú user_log_dirzUnix.user_log_dir}s=€ð×"Ñ"ˆØ �<Š<Ü—7‘7—<‘<  eÓ,ˆDØ × -Ñ -¨dÔ 3؈ rcó—tdd«S)zC:return: documents directory tied to the user, e.g. ``~/Documents``ÚXDG_DOCUMENTS_DIRz ~/Documents©Ú_get_user_media_dirr9s r Úuser_documents_dirzUnix.user_documents_dir†s€ô#Ð#6¸ ÓFÐFrcó—tdd«S)zC:return: downloads directory tied to the user, e.g. ``~/Downloads``ÚXDG_DOWNLOAD_DIRz ~/DownloadsrEr9s r Úuser_downloads_dirzUnix.user_downloads_dir‹s€ô#Ð#5°}ÓEÐErcó—tdd«S)zA:return: pictures directory tied to the user, e.g. ``~/Pictures``ÚXDG_PICTURES_DIRz ~/PicturesrEr9s r Úuser_pictures_dirzUnix.user_pictures_dir�s€ô#Ð#5°|ÓDÐDrcó—tdd«S)z=:return: videos directory tied to the user, e.g. ``~/Videos``ÚXDG_VIDEOS_DIRz~/VideosrEr9s r Úuser_videos_dirzUnix.user_videos_dir•s€ô#Ð#3°ZÓ@Ð@rcó—tdd«S)z;:return: music directory tied to the user, e.g. ``~/Music``Ú XDG_MUSIC_DIRz~/MusicrEr9s r Úuser_music_dirzUnix.user_music_diršs€ô# ?°IÓ>Ð>rcó—tdd«S)z?:return: desktop directory tied to the user, e.g. ``~/Desktop``ÚXDG_DESKTOP_DIRz ~/DesktoprEr9s r Úuser_desktop_dirzUnix.user_desktop_dirŸs€ô#Ð#4°kÓBÐBrcóD—tjjdd«}|j«s`tj j d«r4dt«›�}t|«j«sdt«›�}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_DIRr©ÚfreebsdÚopenbsdÚnetbsdz/var/run/user/z /tmp/runtime-z /run/user/) rrrrÚsysÚplatformÚ startswithrrÚexistsrrs r Úuser_runtime_dirzUnix.user_runtime_dir¤s€€ô�z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|Ü�|‰|×&Ñ&Ð'GÔHØ'¬« zÐ2�ܘD“z×(Ñ(Ô*Ø*¬6«8¨*Ð5‘Dà#¤F£H :Ð.�Ø×0Ñ0°Ó6Ð6rcóÌ—tjjdd«}|j«s$tj j d«rd}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. rXrrYz/var/runz/run)rrrrr]r^r_rrs r Úsite_runtime_dirzUnix.site_runtime_dir¸sP€ô�z‰z�~‰~Ð/°Ó4ˆØ�z‰zŒ|Ü�|‰|×&Ñ&Ð'GÔHØ!‘à�Ø×0Ñ0°Ó6Ð6rcó8—|j|j«S)zd:return: data path shared by users. Only return first item, even if ``multipath`` is set to ``True``)Ú _first_item_as_path_if_multipathr,r9s r Úsite_data_pathzUnix.site_data_pathÎs€ð×4Ñ4°T×5GÑ5GÓHÐHrcó8—|j|j«S)zj:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``)rer4r9s r Úsite_config_pathzUnix.site_config_pathÓs€ð×4Ñ4°T×5IÑ5IÓJÐJrcó8—|j|j«S)ze:return: cache path shared by users. Only return first item, even if ``multipath`` is set to ``True``)rer:r9s r Úsite_cache_pathzUnix.site_cache_pathØs€ð×4Ñ4°T×5HÑ5HÓIÐIrcót—|jr"|jtj«d}t |«S)Nr)r(r#rr"r)rÚ directorys r rez%Unix._first_item_as_path_if_multipathÝs*€Ø �>Š>à!Ÿ™¬¯ © Ó3°AÑ6ˆIÜ�I‹Ðrc#óTK—|j–—|jEd{–—†y7Œ­w)z4:yield: all user and site configuration directories.N)r/r2r9s r Úiter_config_dirszUnix.iter_config_dirsãs!èø€à×"Ñ"Ò"Ø×)Ñ)×)Ò)úó ‚( &¡(c#óTK—|j–—|jEd{–—†y7Œ­w)z+:yield: all user and site data directories.N)rr&r9s r Úiter_data_dirszUnix.iter_data_dirsès!èø€à× Ñ Ò Ø×'Ñ'×'Ò'úroN)ÚreturnÚstr)rrz list[str])rrr)rlrsrrr)rrz Iterator[str])Ú__name__Ú __module__Ú __qualname__Ú__doc__Úpropertyrr&r,r/r2r4r7r:r=rBrGrJrMrPrSrVrarcrfrhrjrernrq©rr rrs΄ñ ðò7óð7ðòVóðVð ò %óð %ðò7óð7ðòVóðVð ò %óð %ðò7óð7ðò?óð?ðò7óð7ðòóððòGóðGðòFóðFðòEóðEðòAóðAðò?óð?ðòCóðCðò7óð7ð&ò7óð7ð*òIóðIðòKóðKðòJóðJóó *ô (rrcó¾—t|«}|€Otjj|d«j «}|stj j |«}|S)Nr)Ú_get_user_dirs_folderrrrrrr)Úenv_varÚfallback_tilde_pathÚ media_dirs r rFrFîsM€Ü% gÓ.€IØÐÜ—J‘J—N‘N 7¨BÓ/×5Ñ5Ó7ˆ ÙÜŸ™×*Ñ*Ð+>Ó?ˆIà Ðrcó¢—tt«j«dz }|j«r“t «}|j «5}|j d|j«›�«ddd«||dvry|d|jd«}|jdtjjd««Sy#1swYŒXxYw)zkReturn directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/.zuser-dirs.dirsz[top] NÚtopÚ"z$HOMEÚ~) rrr/r`rÚopenÚ read_stringÚreadrÚreplacerrr)ÚkeyÚuser_dirs_config_pathÚparserÚstreamrs r r{r{øs²€ä ¤£×!7Ñ!7Ó8Ð;KÑKÐØ×#Ñ#Ô%Ü“ˆà "× 'Ñ 'Ô )¨Và × Ñ  ¨¯©«¨Ð8Ô 9÷*ð �f˜U‘mÑ #Øà�e‰}˜SÑ!×'Ñ'¨Ó,ˆà�|‰|˜G¤R§W¡W×%7Ñ%7¸Ó%<Ó=Ð=à ÷*Ð )ús Á #CÃC)rrÚint)r|rsr}rsrrrs)r‡rsrrz str | None)rwÚ __future__rrr]Ú configparserrÚpathlibrÚtypingrÚapirr^rrrFr{Ú__all__ryrr Úr’sXðÙ å"ã Û Ý%ÝÝå à‡<�<�7Òô õ ôT(ˆ?ôT(ónóð* ð �r