o
    wi                     @  s   d Z ddlmZ ddlZddlZddlmZ erddlm	Z	 ddl
mZ ddlmZ er2dd	lmZ G d
d deZG dd deeZdgZdS )zmacOS.    )annotationsN)TYPE_CHECKING)Iterator   )XDGMixin)PlatformDirsABC)Pathc                   @  s  e Zd ZdZed>ddZed?ddZed@d
dZed>ddZed?ddZ	ed>ddZ
ed>ddZed@ddZed>ddZed>ddZed>ddZed>ddZed>ddZed>d d!Zed>d"d#Zed>d$d%Zed>d&d'Zed>d(d)Zed>d*d+Zed>d,d-Zed>d.d/Zed?d0d1Zed>d2d3Zed>d4d5Zed>d6d7ZdAd9d:ZdAd;d<Zd=S )B_MacOSDefaultsa  Default platform directories for macOS without XDG environment variable overrides.

    Follows the guidance from `Apple's File System Programming Guide
    <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
    The XDG env var handling is in :class:`~platformdirs._xdg.XDGMixin`.

    returnstrc                 C     |  tjdS )zc:returns: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``z~/Library/Application Support_append_app_name_and_versionospath
expanduserself r   O/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/platformdirs/macos.pyuser_data_dir      z_MacOSDefaults.user_data_dir	list[str]c                 C  sP   dt jv }|rt jdd nd}|r| | dgng }|| d |S )N/opt/pythonr    z/sharez/Library/Application Support)sysprefixsplitr   appendr   is_homebrewhomebrew_prefix	path_listr   r   r   _site_data_dirs!   s
   
z_MacOSDefaults._site_data_dirsr   c                 C     |  | jS )zi:returns: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``) _first_item_as_path_if_multipathsite_data_dirr   r   r   r   site_data_path)      z_MacOSDefaults.site_data_pathc                 C     | j S )zD:returns: config directory tied to the user, same as `user_data_dir`r   r   r   r   r   user_config_dir.      z_MacOSDefaults.user_config_dirc                 C  r)   )N)r#   r   r   r   r   _site_config_dirs3      z _MacOSDefaults._site_config_dirsc                 C  r   )zW:returns: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``z~/Library/Cachesr   r   r   r   r   user_cache_dir7   r   z_MacOSDefaults.user_cache_dirc                 C  sf   dt jv }|rt jdd nd}|r| | dgng }|| d | jr/tj|S |d S )a  :returns: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``. If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory will be under the Homebrew prefix, e.g. ``$homebrew_prefix/var/cache/$appname/$version``. If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew, the response is a multi-path string separated by ":", e.g. ``$homebrew_prefix/var/cache/$appname/$version:/Library/Caches/$appname/$version``r   r   r   z
/var/cachez/Library/Caches)	r   r   r   r   r   	multipathr   pathsepjoinr   r   r   r   site_cache_dir<   s   
z_MacOSDefaults.site_cache_dirc                 C  r$   )zj:returns: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``)r%   r3   r   r   r   r   site_cache_pathG   r(   z_MacOSDefaults.site_cache_pathc                 C  r)   )zC:returns: state directory tied to the user, same as `user_data_dir`r*   r   r   r   r   user_state_dirL   r,   z_MacOSDefaults.user_state_dirc                 C  r)   )zB:returns: state directory shared by users, same as `site_data_dir`)r&   r   r   r   r   site_state_dirQ   r,   z_MacOSDefaults.site_state_dirc                 C  r   )zS:returns: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``z~/Library/Logsr   r   r   r   r   user_log_dirV   r   z_MacOSDefaults.user_log_dirc                 C  s
   |  dS )zQ:returns: log directory shared by users, e.g. ``/Library/Logs/$appname/$version``z/Library/Logs)r   r   r   r   r   site_log_dir[   s   
z_MacOSDefaults.site_log_dirc                 C     t jdS )zD:returns: documents directory tied to the user, e.g. ``~/Documents``z~/Documentsr   r   r   r   r   r   r   user_documents_dir`   r(   z!_MacOSDefaults.user_documents_dirc                 C  r9   )zD:returns: downloads directory tied to the user, e.g. ``~/Downloads``z~/Downloadsr:   r   r   r   r   user_downloads_dire   r(   z!_MacOSDefaults.user_downloads_dirc                 C  r9   )zB:returns: pictures directory tied to the user, e.g. ``~/Pictures``z
~/Picturesr:   r   r   r   r   user_pictures_dirj   r(   z _MacOSDefaults.user_pictures_dirc                 C  r9   )z>:returns: videos directory tied to the user, e.g. ``~/Movies``z~/Moviesr:   r   r   r   r   user_videos_diro   r(   z_MacOSDefaults.user_videos_dirc                 C  r9   )z<:returns: music directory tied to the user, e.g. ``~/Music``z~/Musicr:   r   r   r   r   user_music_dirt   r(   z_MacOSDefaults.user_music_dirc                 C  r9   )z@:returns: desktop directory tied to the user, e.g. ``~/Desktop``z	~/Desktopr:   r   r   r   r   user_desktop_diry   r(   z_MacOSDefaults.user_desktop_dirc                 C  r9   )z?:returns: bin directory tied to the user, e.g. ``~/.local/bin``z~/.local/binr:   r   r   r   r   user_bin_dir~   r(   z_MacOSDefaults.user_bin_dirc                 C  s   dS )z@:returns: bin directory shared by users, e.g. ``/usr/local/bin``z/usr/local/binr   r   r   r   r   site_bin_dir   s   z_MacOSDefaults.site_bin_dirc                 C  r9   )zJ:returns: applications directory tied to the user, e.g. ``~/Applications``z~/Applicationsr:   r   r   r   r   user_applications_dir   r(   z$_MacOSDefaults.user_applications_dirc                 C  s   dgS )Nz/Applicationsr   r   r   r   r   _site_applications_dirs   r.   z&_MacOSDefaults._site_applications_dirsc                 C  s    | j }| jrtj|S |d S )zH:returns: applications directory shared by users, e.g. ``/Applications``r   )rD   r0   r   r1   r2   )r   dirsr   r   r   site_applications_dir   s   z$_MacOSDefaults.site_applications_dirc                 C  r   )zh:returns: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``z~/Library/Caches/TemporaryItemsr   r   r   r   r   user_runtime_dir   r   z_MacOSDefaults.user_runtime_dirc                 C  r)   )zG:returns: runtime directory shared by users, same as `user_runtime_dir`)rG   r   r   r   r   site_runtime_dir   r,   z_MacOSDefaults.site_runtime_dirIterator[str]c                 c      | j V  | jE dH  dS )z4:yield: all user and site configuration directories.N)r+   r-   r   r   r   r   iter_config_dirs      z_MacOSDefaults.iter_config_dirsc                 c  rJ   )z+:yield: all user and site data directories.N)r   r#   r   r   r   r   iter_data_dirs   rL   z_MacOSDefaults.iter_data_dirsN)r
   r   )r
   r   )r
   r   )r
   rI   ) __name__
__module____qualname____doc__propertyr   r#   r'   r+   r-   r/   r3   r4   r5   r6   r7   r8   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rF   rG   rH   rK   rM   r   r   r   r   r	      sl    

r	   c                   @  s   e Zd ZdZdS )MacOSaF  Platform directories for the macOS operating system.

    Follows the guidance from `Apple documentation
    <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
    Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version
    <platformdirs.api.PlatformDirsABC.version>`, `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.

    XDG environment variables (e.g. ``$XDG_DATA_HOME``) are supported and take precedence over macOS defaults.

    N)rN   rO   rP   rQ   r   r   r   r   rS      s    rS   )rQ   
__future__r   os.pathr   r   typingr   collections.abcr   _xdgr   apir   pathlibr   r	   rS   __all__r   r   r   r   <module>   s      