o 1b@sddlmZddlZddlZddlZddlmZddlmZddl m Z Gddde Z edd dd d Z edd dddZ dgZdS)) annotationsN) lru_cache)cast)PlatformDirsABCc@seZdZdZedddZedddZeddd Zedd d Zedd d Z edddZ edddZ edddZ edddZ dS)Androidz Follows the guidance `from here `_. Makes use of the `appname ` and `version `. returnstrcC|tttdS)zd:return: data directory tied to the user, e.g. ``/data/user///files/``files_append_app_name_and_versionrr _android_folderselfr6/usr/lib/python3/dist-packages/platformdirs/android.py user_data_dirzAndroid.user_data_dircC|jS)z@:return: data directory shared by users, same as `user_data_dir`rrrrr site_data_dirzAndroid.site_data_dircCr )z :return: config directory tied to the user, e.g. ``/data/user///shared_prefs/`` shared_prefsr rrrruser_config_dirszAndroid.user_config_dircCr)zH:return: config directory shared by the users, same as `user_config_dir`)rrrrrsite_config_dir$rzAndroid.site_config_dircCr )zj:return: cache directory tied to the user, e.g. e.g. ``/data/user///cache/``cacher rrrruser_cache_dir)rzAndroid.user_cache_dircCr)zB:return: state directory tied to the user, same as `user_data_dir`rrrrruser_state_dir.rzAndroid.user_state_dircC|j}|jr tj|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_dir3zAndroid.user_log_dircCstS)zf :return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents`` )_android_documents_folderrrrruser_documents_dir>szAndroid.user_documents_dircCr)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`` tmpr!r&rrruser_runtime_dirEr(zAndroid.user_runtime_dirNrr )__name__ __module__ __qualname____doc__propertyrrrrrrr'r*r,rrrrr s(        r)maxsizer str | NonecCszzddlm}|d}|}W|Sty<td}tj D]}| |r6| dd}Y|Sq$d}Y|Sw)zB:return: base folder for the Android OS or None if cannot be foundr autoclassandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesN) jniusr6 getFilesDir getParentFilegetAbsolutePath Exceptionrecompilesysr$matchsplit)r6Contextresultpatternr$rrrrQs     rr cCsLzddlm}|d}|d}||j}W|Sty%d}Y|Sw)z,:return: documents folder for the Android OSrr5r7zandroid.os.Environmentz/storage/emulated/0/Documents)r8r6getExternalFilesDirDIRECTORY_DOCUMENTSr;r<)r6rB Environment documents_dirrrrr)fs  r))rr4r-) __future__rr#r=r? functoolsrtypingrapirrrr)__all__rrrrs    E