
    d                    |   d Z 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 ed
          dd            Z ed
          dd            Z ed
          dd            Z ed
          dd            Zd	gZdS )zAndroid.    )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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    X/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/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_dir1   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_dir6   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_dir;   0     "< 	-7<<e,,Dr   c                    t                      S )zT:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``)_android_documents_folderr   s    r   user_documents_dirzAndroid.user_documents_dirF        )***r   c                    t                      S )zT:return: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``)_android_downloads_folderr   s    r   user_downloads_dirzAndroid.user_downloads_dirK   r4   r   c                    t                      S )zR:return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``)_android_pictures_folderr   s    r   user_pictures_dirzAndroid.user_pictures_dirP   s     ()))r   c                    t                      S )zS:return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``)_android_videos_folderr   s    r   user_videos_dirzAndroid.user_videos_dirU   s     &'''r   c                    t                      S )zL:return: music directory tied to the user e.g. ``/storage/emulated/0/Music``)_android_music_folderr   s    r   user_music_dirzAndroid.user_music_dirZ   s     %&&&r   c                    dS )zP:return: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``z/storage/emulated/0/Desktop r   s    r   user_desktop_dirzAndroid.user_desktop_dir_   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_dird   r0   r   c                    | j         S )zF:return: runtime directory shared by users, same as `user_runtime_dir`)rF   r   s    r   site_runtime_dirzAndroid.site_runtime_diro   s     $$r   Nr
   r   )__name__
__module____qualname____doc__propertyr   r   r   r   r"   r$   r&   r/   r3   r7   r:   r=   r@   rC   rF   rH   rB   r   r   r	   r	      s*         X X X XX " " " X" _ _ _ 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 )zE:return: base folder for the Android OS or None if it cannot be foundr   	autoclassandroid.content.Contextz /data/(data|user/\d+)/(.+)/filesz/filesN)jniusrS   getFilesDirgetParentFilegetAbsolutePath	Exceptionrecompilesysr,   matchsplit)rS   contextresultpatternr,   s        r   r   r   u   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   rR   rT   android.os.Environmentz/storage/emulated/0/Documents)rU   rS   getExternalFilesDirDIRECTORY_DOCUMENTSrX   rY   )rS   r_   environmentdocuments_dirs       r   r2   r2          8######)566i 899$889XYYiikk 8 8 878    AA AAc                     	 ddl m}   | d          } | d          }|                    |j                                                  }n# t
          $ r d}Y nw xY w|S )z,:return: downloads folder for the Android OSr   rR   rT   rc   z/storage/emulated/0/Downloads)rU   rS   rd   DIRECTORY_DOWNLOADSrX   rY   )rS   r_   rf   downloads_dirs       r   r6   r6      rh   ri   c                     	 ddl m}   | d          } | d          }|                    |j                                                  }n# t
          $ r d}Y nw xY w|S )z+:return: pictures folder for the Android OSr   rR   rT   rc   z/storage/emulated/0/Pictures)rU   rS   rd   DIRECTORY_PICTURESrX   rY   )rS   r_   rf   pictures_dirs       r   r9   r9      s    6######)566i 899#778VWWggii 6 6 656 ri   c                     	 ddl m}   | d          } | d          }|                    |j                                                  }n# t
          $ r d}Y nw xY w|S )z):return: videos folder for the Android OSr   rR   rT   rc   z/storage/emulated/0/DCIM/Camera)rU   rS   rd   DIRECTORY_DCIMrX   rY   )rS   r_   rf   
videos_dirs       r   r<   r<      s    7######)566i 899!55k6PQQaacc

 7 7 76


7 ri   c                     	 ddl m}   | d          } | d          }|                    |j                                                  }n# t
          $ r d}Y nw xY w|S )z(:return: music folder for the Android OSr   rR   rT   rc   z/storage/emulated/0/Music)rU   rS   rd   DIRECTORY_MUSICrX   rY   )rS   r_   rf   	music_dirs       r   r?   r?      s    0######)566i 899 44[5PQQaacc		 0 0 0/			0 ri   )r
   rP   rI   )rM   
__future__r   r+   rZ   r\   	functoolsr   typingr   apir   r	   r   r2   r6   r9   r<   r?   __all__rB   r   r   <module>r{      s    " " " " " " 				 				 



                        e% e% e% e% e%o e% e% e%P 1   ( 1    1    1    1    1     r   