o
    b                     @   sz   d dl Z d dlZd dlZd dlmZ ddlmZ G dd deZedddefd	d
Z	edddefddZ
dgZdS )    N)	lru_cache   )PlatformDirsABCc                   @   s   e Zd ZdZedefddZedefddZedefddZedefd	d
Z	edefddZ
edefddZedefddZedefddZedef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>`.
    returnc                 C      |  t dS )zd:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``files_append_app_name_and_version_android_folderself r   S/var/www/secure340b-portal/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: state directory tied to the user, same as `user_data_dir`r   r   r   r   r   user_state_dir+   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_dir0      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   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_dirB   r$   zAndroid.user_runtime_dirN)__name__
__module____qualname____doc__propertystrr   r   r   r   r   r   r#   r&   r(   r   r   r   r   r   	   s(    
r   )maxsizer   c                  C   sx   zddl m}  | d}|   }W |S  ty;   td}tj	D ]}|
|r6|dd } Y |S q$tdw )z':return: base folder for the Android OSr   	autoclassandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesz&Cannot find path to android app folder)jniusr1   ZgetFilesDirZgetParentFilegetAbsolutePath	Exceptionrecompilesysr    matchsplitOSError)r1   Contextresultpatternr    r   r   r   r   N   s   



r   c                  C   sL   zddl m}  | d}| d}||j }W |S  ty%   d}Y |S w )z,:return: documents folder for the Android OSr   r0   r2   zandroid.os.Environmentz/storage/emulated/0/Documents)r3   r1   ZgetExternalFilesDirZDIRECTORY_DOCUMENTSr4   r5   )r1   r<   Environmentdocuments_dirr   r   r   r%   c   s   r%   )r   r6   r8   	functoolsr   apir   r   r.   r   r%   __all__r   r   r   r   <module>   s    E