o
    Zh                     @  s   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ G dd	 d	eZedd
dddZedd
dddZedd
dddZedd
dddZedd
dddZedd
dddZd	gZdS )zAndroid.    )annotationsN)	lru_cache)cast   )PlatformDirsABCc                   @  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d$S )&Androida$  
    Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the
    `appname <platformdirs.api.PlatformDirsABC.appname>`,
    `version <platformdirs.api.PlatformDirsABC.version>`,
    `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
    returnstrc                 C     |  ttt dS )zd:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``files_append_app_name_and_versionr   r	   _android_folderself r   K/var/www/html/lang_env/lib/python3.10/site-packages/platformdirs/android.pyuser_data_dir      zAndroid.user_data_dirc                 C     | j S )z@:return: data directory shared by users, same as `user_data_dir`r   r   r   r   r   site_data_dir      zAndroid.site_data_dirc                 C  r
   )z
        :return: config directory tied to the user, e.g.         ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``
        Zshared_prefsr   r   r   r   r   user_config_dir   s   zAndroid.user_config_dirc                 C  r   )zH:return: config directory shared by the users, same as `user_config_dir`)r   r   r   r   r   site_config_dir'   r   zAndroid.site_config_dirc                 C  r
   )zj:return: cache directory tied to the user, e.g. e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>``cacher   r   r   r   r   user_cache_dir,   r   zAndroid.user_cache_dirc                 C  r   )zB:return: cache directory shared by users, same as `user_cache_dir`)r   r   r   r   r   site_cache_dir1   r   zAndroid.site_cache_dirc                 C  r   )zB:return: state directory tied to the user, same as `user_data_dir`r   r   r   r   r   user_state_dir6   r   zAndroid.user_state_dirc                 C     | j }| jrtj|d}|S )z
        :return: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it,
          e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log``
        logr   opinionospathjoinr   r$   r   r   r   user_log_dir;      zAndroid.user_log_dirc                 C     t  S )zT:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``)_android_documents_folderr   r   r   r   user_documents_dirF   r   zAndroid.user_documents_dirc                 C  r)   )zT:return: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``)_android_downloads_folderr   r   r   r   user_downloads_dirK   r   zAndroid.user_downloads_dirc                 C  r)   )zR:return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``)_android_pictures_folderr   r   r   r   user_pictures_dirP   r   zAndroid.user_pictures_dirc                 C  r)   )zS:return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``)_android_videos_folderr   r   r   r   user_videos_dirU   r   zAndroid.user_videos_dirc                 C  r)   )zL:return: music directory tied to the user e.g. ``/storage/emulated/0/Music``)_android_music_folderr   r   r   r   user_music_dirZ   r   zAndroid.user_music_dirc                 C  s   dS )zP:return: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``z/storage/emulated/0/Desktopr   r   r   r   r   user_desktop_dir_   s   zAndroid.user_desktop_dirc                 C  r   )z
        :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it,
          e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp``
        tmpr!   r&   r   r   r   user_runtime_dird   r(   zAndroid.user_runtime_dirc                 C  r   )zF:return: runtime directory shared by users, same as `user_runtime_dir`)r6   r   r   r   r   site_runtime_diro   r   zAndroid.site_runtime_dirNr   r	   )__name__
__module____qualname____doc__propertyr   r   r   r   r   r   r   r'   r+   r-   r/   r1   r3   r4   r6   r7   r   r   r   r   r      sD    

r   )maxsizer   
str | Nonec                  C  sz   zddl m}  | d}|   }W |S  ty<   td}tj	D ]}|
|r6|dd } Y |S q$d}Y |S w )zE:return: base folder for the Android OS or None if it cannot be foundr   	autoclassandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesN)jniusrA   ZgetFilesDirZgetParentFilegetAbsolutePath	Exceptionrecompilesysr$   matchsplit)rA   contextresultpatternr$   r   r   r   r   u   s    



r   r	   c                  C  L   zddl m}  | d}| d}||j }W |S  ty%   d}Y |S w )z,:return: documents folder for the Android OSr   r@   rB   android.os.Environmentz/storage/emulated/0/Documents)rC   rA   getExternalFilesDirZDIRECTORY_DOCUMENTSrD   rE   )rA   rK   environmentZdocuments_dirr   r   r   r*         r*   c                  C  rN   )z,:return: downloads folder for the Android OSr   r@   rB   rO   z/storage/emulated/0/Downloads)rC   rA   rP   ZDIRECTORY_DOWNLOADSrD   rE   )rA   rK   rQ   Zdownloads_dirr   r   r   r,      rR   r,   c                  C  rN   )z+:return: pictures folder for the Android OSr   r@   rB   rO   z/storage/emulated/0/Pictures)rC   rA   rP   ZDIRECTORY_PICTURESrD   rE   )rA   rK   rQ   Zpictures_dirr   r   r   r.      rR   r.   c                  C  rN   )z):return: videos folder for the Android OSr   r@   rB   rO   z/storage/emulated/0/DCIM/Camera)rC   rA   rP   ZDIRECTORY_DCIMrD   rE   )rA   rK   rQ   Z
videos_dirr   r   r   r0      rR   r0   c                  C  rN   )z(:return: music folder for the Android OSr   r@   rB   rO   z/storage/emulated/0/Music)rC   rA   rP   ZDIRECTORY_MUSICrD   rE   )rA   rK   rQ   Z	music_dirr   r   r   r2      rR   r2   )r   r?   r8   )r<   
__future__r   r#   rF   rH   	functoolsr   typingr   apir   r   r   r*   r,   r.   r0   r2   __all__r   r   r   r   <module>   s.    h