U e@sdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z Gdd d e Z edd d d d dZ edd dd ddZedd dd ddZedd dd ddZedd dd ddZedd dd ddZd gZdS)zAndroid.) annotationsN) lru_cache)cast)PlatformDirsABCc@s0eZdZdZeddddZeddddZedddd Zeddd d Zeddd d Z eddddZ eddddZ eddddZ eddddZ eddddZeddddZeddddZeddddZeddddZeddd d!Zeddd"d#Zd$S)%Androida$ Follows the guidance `from here `_. Makes use of the `appname `, `version `, `ensure_exists `. strreturncCs|tttdS)zd:return: data directory tied to the user, e.g. ``/data/user///files/``files_append_app_name_and_versionrr_android_folderselfrB/opt/hc_python/lib/python3.8/site-packages/platformdirs/android.py user_data_dirszAndroid.user_data_dircCs|jS)z@:return: data directory shared by users, same as `user_data_dir`rrrrr site_data_dirszAndroid.site_data_dircCs|tttdS)z :return: config directory tied to the user, e.g. ``/data/user///shared_prefs/`` Z shared_prefsr rrrruser_config_dir szAndroid.user_config_dircCs|jS)zH:return: config directory shared by the users, same as `user_config_dir`)rrrrrsite_config_dir(szAndroid.site_config_dircCs|tttdS)zj:return: cache directory tied to the user, e.g. e.g. ``/data/user///cache/``cacher rrrruser_cache_dir-szAndroid.user_cache_dircCs|jS)zB:return: cache directory shared by users, same as `user_cache_dir`)rrrrrsite_cache_dir2szAndroid.site_cache_dircCs|jS)zB:return: state directory tied to the user, same as `user_data_dir`rrrrruser_state_dir7szAndroid.user_state_dircCs|j}|jrtj|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///cache//log`` logropinionospathjoinrr rrr user_log_dir<szAndroid.user_log_dircCstS)zT:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``)_android_documents_folderrrrruser_documents_dirGszAndroid.user_documents_dircCstS)zT:return: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``)_android_downloads_folderrrrruser_downloads_dirLszAndroid.user_downloads_dircCstS)zR:return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``)_android_pictures_folderrrrruser_pictures_dirQszAndroid.user_pictures_dircCstS)zS:return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``)_android_videos_folderrrrruser_videos_dirVszAndroid.user_videos_dircCstS)zL:return: music directory tied to the user e.g. ``/storage/emulated/0/Music``)_android_music_folderrrrruser_music_dir[szAndroid.user_music_dircCsdS)zP:return: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``z/storage/emulated/0/Desktoprrrrruser_desktop_dir`szAndroid.user_desktop_dircCs|j}|jrtj|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///cache//tmp`` tmprr"rrruser_runtime_direszAndroid.user_runtime_dircCs|jS)zF:return: runtime directory shared by users, same as `user_runtime_dir`)r0rrrrsite_runtime_dirpszAndroid.site_runtime_dirN)__name__ __module__ __qualname____doc__propertyrrrrrrrr#r%r'r)r+r-r.r0r1rrrrrsB  r)maxsizez str | Noner cCsxz(ddlm}|d}|}WnJtk rrtd}tj D] }| |rH| dd}qnqHd}YnX|S)zE:return: base folder for the Android OS or None if it cannot be foundr autoclassandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesN) jniusr9Z getFilesDirZ getParentFilegetAbsolutePath Exceptionrecompilesysr matchsplit)r9contextresultpatternr rrrrvs     rrcCsNz0ddlm}|d}|d}||j}Wntk rHd}YnX|S)z,:return: documents folder for the Android OSrr8r:android.os.Environmentz/storage/emulated/0/Documents)r;r9getExternalFilesDirZDIRECTORY_DOCUMENTSr<r=)r9rC environmentZ documents_dirrrrr$s  r$cCsNz0ddlm}|d}|d}||j}Wntk rHd}YnX|S)z,:return: downloads folder for the Android OSrr8r:rFz/storage/emulated/0/Downloads)r;r9rGZDIRECTORY_DOWNLOADSr<r=)r9rCrHZ downloads_dirrrrr&s  r&cCsNz0ddlm}|d}|d}||j}Wntk rHd}YnX|S)z+:return: pictures folder for the Android OSrr8r:rFz/storage/emulated/0/Pictures)r;r9rGZDIRECTORY_PICTURESr<r=)r9rCrHZ pictures_dirrrrr(s  r(cCsNz0ddlm}|d}|d}||j}Wntk rHd}YnX|S)z):return: videos folder for the Android OSrr8r:rFz/storage/emulated/0/DCIM/Camera)r;r9rGZDIRECTORY_DCIMr<r=)r9rCrHZ videos_dirrrrr*s  r*cCsNz0ddlm}|d}|d}||j}Wntk rHd}YnX|S)z(:return: music folder for the Android OSrr8r:rFz/storage/emulated/0/Music)r;r9rGZDIRECTORY_MUSICr<r=)r9rCrHZ music_dirrrrr,s  r,)r5 __future__rrr>r@ functoolsrtypingrapirrrr$r&r(r*r,__all__rrrrs,    h