o
    i(                     @  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	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)TYPE_CHECKINGcast   )PlatformDirsABCc                   @  sD  e Zd ZdZed1ddZed1ddZed1dd	Zed1d
dZed1ddZ	ed1ddZ
ed1ddZed1ddZed1ddZed1ddZed1ddZed1ddZed1ddZed1ddZed1d d!Zed1d"d#Zed1d$d%Zed1d&d'Zed1d(d)Zed1d*d+Zed1d,d-Zed1d.d/Zd0S )2Androida  Platform directories for Android.

    Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Directories are typically located
    under the app's private storage (``/data/user/<userid>/<packagename>/``).

    Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version
    <platformdirs.api.PlatformDirsABC.version>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
    <platformdirs.api.PlatformDirsABC.ensure_exists>`.

    returnstrc                 C     |  tdt dS )ze:returns: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``r
   files_append_app_name_and_versionr   _android_folderself r   R/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/platformdirs/android.pyuser_data_dir      zAndroid.user_data_dirc                 C     | j S )zA:returns: 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   )zn:returns: config directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``r
   shared_prefsr   r   r   r   r   user_config_dir$   r   zAndroid.user_config_dirc                 C  r   )zE:returns: config directory shared by users, same as `user_config_dir`)r   r   r   r   r   site_config_dir)   r   zAndroid.site_config_dirc                 C  r   )zf:returns: cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``r
   cacher   r   r   r   r   user_cache_dir.   r   zAndroid.user_cache_dirc                 C  r   )zC:returns: cache directory shared by users, same as `user_cache_dir`)r   r   r   r   r   site_cache_dir3   r   zAndroid.site_cache_dirc                 C  r   )zC:returns: state directory tied to the user, same as `user_data_dir`r   r   r   r   r   user_state_dir8   r   zAndroid.user_state_dirc                 C  r   )zC:returns: state directory shared by users, same as `user_state_dir`)r    r   r   r   r   site_state_dir=   r   zAndroid.site_state_dirc                 C     | j }| jrtj|d}|S )z:returns: 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_dirB      zAndroid.user_log_dirc                 C  r   )z?:returns: log directory shared by users, same as `user_log_dir`)r*   r   r   r   r   site_log_dirJ   r   zAndroid.site_log_dirc                 C     t  S )zU:returns: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``)_android_documents_folderr   r   r   r   user_documents_dirO   r   zAndroid.user_documents_dirc                 C  r-   )zU:returns: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``)_android_downloads_folderr   r   r   r   user_downloads_dirT   r   zAndroid.user_downloads_dirc                 C  r-   )zS:returns: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``)_android_pictures_folderr   r   r   r   user_pictures_dirY   r   zAndroid.user_pictures_dirc                 C  r-   )zT:returns: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``)_android_videos_folderr   r   r   r   user_videos_dir^   r   zAndroid.user_videos_dirc                 C  r-   )zM:returns: music directory tied to the user e.g. ``/storage/emulated/0/Music``)_android_music_folderr   r   r   r   user_music_dirc   r   zAndroid.user_music_dirc                 C  s   dS )zQ:returns: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``z/storage/emulated/0/Desktopr   r   r   r   r   user_desktop_dirh   s   zAndroid.user_desktop_dirc                 C  s   t jtdt ddS )z^:returns: bin directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/bin``r
   r   bin)r&   r'   r(   r   r   r   r   r   r   user_bin_dirm   s   zAndroid.user_bin_dirc                 C  r   )z?:returns: bin directory shared by users, same as `user_bin_dir`)r:   r   r   r   r   site_bin_dirr   r   zAndroid.site_bin_dirc                 C  r   )zJ:returns: applications directory tied to the user, same as `user_data_dir`r   r   r   r   r   user_applications_dirw   r   zAndroid.user_applications_dirc                 C  r   )zQ:returns: applications directory shared by users, same as `user_applications_dir`)r<   r   r   r   r   site_applications_dir|   r   zAndroid.site_applications_dirc                 C  r"   )z:returns: 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_dir   r+   zAndroid.user_runtime_dirc                 C  r   )zG:returns: runtime directory shared by users, same as `user_runtime_dir`)r?   r   r   r   r   site_runtime_dir   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   r5   r7   r8   r:   r;   r<   r=   r?   r@   r   r   r   r   r      s\    r   )maxsizer	   
str | Nonec                  C  s  d} t s'zddlm} td| }|   } W n ty&   d} Y nw | du rKzddl	m
} |d}|   } W n tyJ   d} Y nw | du rjtd}tjD ]}||rg|dd }  nqWd} | du rtd}tjD ]}||r|dd }  | S qvd} | S )	zF:returns: base folder for the Android OS or None if it cannot be foundNr   )	mActivityandroid.content.Context	autoclassz /data/(data|user/\d+)/(.+)/filesz/filesz7/mnt/expand/[a-fA-F0-9-]{36}/(data|user/\d+)/(.+)/files)r   androidrI   r   getApplicationContextgetFilesDirgetParentFilegetAbsolutePath	ExceptionjniusrL   recompilesysr'   matchsplit)resultrI   contextrL   patternr'   r   r   r   r      sF   





r   r
   c                  C  L   zddl m}  | d}| d}||j }W |S  ty%   d}Y |S w )z-:returns: documents folder for the Android OSr   rK   rJ   android.os.Environmentz/storage/emulated/0/Documents)rS   rL   getExternalFilesDirDIRECTORY_DOCUMENTSrQ   rR   )rL   rZ   environmentdocuments_dirr   r   r   r.         r.   c                  C  r\   )z-:returns: downloads folder for the Android OSr   rK   rJ   r]   z/storage/emulated/0/Downloads)rS   rL   r^   DIRECTORY_DOWNLOADSrQ   rR   )rL   rZ   r`   downloads_dirr   r   r   r0      rb   r0   c                  C  r\   )z,:returns: pictures folder for the Android OSr   rK   rJ   r]   z/storage/emulated/0/Pictures)rS   rL   r^   DIRECTORY_PICTURESrQ   rR   )rL   rZ   r`   pictures_dirr   r   r   r2      rb   r2   c                  C  r\   )z*:returns: videos folder for the Android OSr   rK   rJ   r]   z/storage/emulated/0/DCIM/Camera)rS   rL   r^   DIRECTORY_DCIMrQ   rR   )rL   rZ   r`   
videos_dirr   r   r   r4      rb   r4   c                  C  r\   )z):returns: music folder for the Android OSr   rK   rJ   r]   z/storage/emulated/0/Music)rS   rL   r^   DIRECTORY_MUSICrQ   rR   )rL   rZ   r`   	music_dirr   r   r   r6      rb   r6   )r	   rH   rA   )rE   
__future__r   r&   rT   rV   	functoolsr   typingr   r   apir   r   r   r.   r0   r2   r4   r6   __all__r   r   r   r   <module>   s0     /