
    Kd                        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e
          Z ed	          dd            Z ed	          dd            ZdgZdS )    )annotationsN)	lru_cache)cast   )PlatformDirsABCc                     e Zd ZdZedd            Zedd            Zedd            Zedd            Zedd            Z	edd	            Z
edd
            Zedd            Zedd            Zedd            ZdS )Androida$  
    Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the
    `appname <platformdirs.api.PlatformDirsABC.appname>`,
    `version <platformdirs.api.PlatformDirsABC.version>`,
    `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
    returnstrc                l    |                      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selfs    FF:\djangOuth\env\Lib\site-packages\pip/_vendor/platformdirs/android.pyuser_data_dirzAndroid.user_data_dir   *     00c?;L;L1M1MwWWW    c                    | j         S )z@:return: data directory shared by users, same as `user_data_dir`r   r   s    r   site_data_dirzAndroid.site_data_dir        !!r   c                l    |                      t          t          t                                d          S )z
        :return: config directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``
        shared_prefsr   r   s    r   user_config_dirzAndroid.user_config_dir   s*    
 00c?;L;L1M1M~^^^r   c                    | j         S )zH:return: config directory shared by the users, same as `user_config_dir`)r   r   s    r   site_config_dirzAndroid.site_config_dir%   s     ##r   c                l    |                      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   s    r   user_cache_dirzAndroid.user_cache_dir*   r   r   c                    | j         S )zB:return: cache directory shared by users, same as `user_cache_dir`)r"   r   s    r   site_cache_dirzAndroid.site_cache_dir/   s     ""r   c                    | j         S )zB:return: state directory tied to the user, same as `user_data_dir`r   r   s    r   user_state_dirzAndroid.user_state_dir4   r   r   c                b    | 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,   s     r   user_log_dirzAndroid.user_log_dir9   0     "< 	-7<<e,,Dr   c                    t                      S )zf
        :return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``
        )_android_documents_folderr   s    r   user_documents_dirzAndroid.user_documents_dirD   s    
 )***r   c                b    | 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.   s     r   user_runtime_dirzAndroid.user_runtime_dirK   r0   r   Nr
   r   )__name__
__module____qualname____doc__propertyr   r   r   r   r"   r$   r&   r/   r3   r6    r   r   r	   r	      sj         X X X XX " " " X" _ _ _ X_ $ $ $ X$ X X X XX # # # X# " " " X"    X + + + X+    X  r   r	   )maxsizer
   
str | Nonec                 j   	 ddl m}   | d          }|                                                                                                }ng# t
          $ rZ t          j        d          }t          j	        D ]4}|
                    |          r|                    d          d         } n5d}Y nw xY w|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)jniusrB   getFilesDirgetParentFilegetAbsolutePath	Exceptionrecompilesysr,   matchsplit)rB   Contextresultpatternr,   s        r   r   r   W   s    ######)566$0022@@BBRRTT   *@AAH 	 	D}}T"" H--a0 F Ms   A	A A!B0/B0r   c                     	 ddl m}   | d          } | d          }|                    |j                                                  }n# t
          $ r d}Y nw xY w|S )z,:return: documents folder for the Android OSr   rA   rC   zandroid.os.Environmentz/storage/emulated/0/Documents)rD   rB   getExternalFilesDirDIRECTORY_DOCUMENTSrG   rH   )rB   rN   Environmentdocuments_dirs       r   r2   r2   l   s    8######)566i 899$889XYYiikk 8 8 878 s   AA AA)r
   r?   r7   )
__future__r   r+   rI   rK   	functoolsr   typingr   apir   r	   r   r2   __all__r=   r   r   <module>r[      s   " " " " " " 				 				 



                        H H H H Ho H H HV 1   ( 1     r   