a
    |Ä#dä  ã                   @  s’   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d„ƒZedd	�ddœdd„ƒZdgZdS )é    )ÚannotationsN)Ú	lru_cache)Úcasté   )ÚPlatformDirsABCc                   @  s²   e Zd ZdZeddœdd„ƒZeddœdd„ƒZeddœdd	„ƒZeddœd
d„ƒZeddœdd„ƒZ	eddœdd„ƒZ
eddœdd„ƒZeddœdd„ƒZeddœdd„ƒZdS )ÚAndroidzá
    Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the
    `appname <platformdirs.api.PlatformDirsABC.appname>` and
    `version <platformdirs.api.PlatformDirsABC.version>`.
    Ústr©Úreturnc                 C  s   |   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   úW/var/www/html/gsl.tools/lib/python3.9/site-packages/pip/_vendor/platformdirs/android.pyÚuser_data_dir   s    zAndroid.user_data_dirc                 C  s   | j S )z@:return: data directory shared by users, same as `user_data_dir`©r   r   r   r   r   Úsite_data_dir   s    zAndroid.site_data_dirc                 C  s   |   tttƒ ƒd¡S )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  s   | j S )zH:return: config directory shared by the users, same as `user_config_dir`)r   r   r   r   r   Úsite_config_dir$   s    zAndroid.site_config_dirc                 C  s   |   tttƒ ƒd¡S )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)   s    zAndroid.user_cache_dirc                 C  s   | j S )zB:return: state directory tied to the user, same as `user_data_dir`r   r   r   r   r   Úuser_state_dir.   s    zAndroid.user_state_dirc                 C  s   | 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_dir3   s    zAndroid.user_log_dirc                 C  s   t ƒ S )zf
        :return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``
        )Ú_android_documents_folderr   r   r   r   Úuser_documents_dir>   s    zAndroid.user_documents_dirc                 C  s   | j }| jrtj |d¡}|S )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_dirE   s    zAndroid.user_runtime_dirN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r   r   r   r   r"   r$   r&   r   r   r   r   r      s&   
r   )Úmaxsizez
str | Noner	   c                  C  sv   z(ddl m}  | dƒ}| ¡  ¡  ¡ }W nH typ   t d¡}tj	D ] }| 
|¡rF| d¡d } qlqFd}Y n0 |S )zB:return: base folder for the Android OS or None if cannot be foundr   ©Ú	autoclassúandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesN)Újniusr.   ZgetFilesDirZgetParentFileÚgetAbsolutePathÚ	ExceptionÚreÚcompileÚsysr   ÚmatchÚsplit)r.   ÚContextÚresultÚpatternr   r   r   r   r   Q   s    



r   r   c                  C  sL   z0ddl m}  | dƒ}| dƒ}| |j¡ ¡ }W n tyF   d}Y n0 |S )z,:return: documents folder for the Android OSr   r-   r/   zandroid.os.Environmentz/storage/emulated/0/Documents)r0   r.   ZgetExternalFilesDirZDIRECTORY_DOCUMENTSr1   r2   )r.   r8   ÚEnvironmentÚdocuments_dirr   r   r   r#   f   s    
r#   )Ú
__future__r   r   r3   r5   Ú	functoolsr   Útypingr   Úapir   r   r   r#   Ú__all__r   r   r   r   Ú<module>   s   Eÿ