| 1 |
''' |
| 2 |
Storage Path |
| 3 |
============ |
| 4 |
|
| 5 |
The StorgePath API can be used to gain access to standard storage locations |
| 6 |
across platforms such as home directory, root directory, external storage |
| 7 |
directory, documents, downloads, etc. |
| 8 |
|
| 9 |
The :class:`StoragePath` provides access to public methods to access standard |
| 10 |
storage locations. |
| 11 |
|
| 12 |
Simple Examples |
| 13 |
--------------- |
| 14 |
|
| 15 |
To get the path of user's home directory:: |
| 16 |
|
| 17 |
>>> from plyer import storagepath |
| 18 |
>>> storagepath.get_home_dir() |
| 19 |
|
| 20 |
To get the path of standard downloads directory:: |
| 21 |
|
| 22 |
>>> from plyer import storagepath |
| 23 |
>>> storagepath.get_downloads_dir() |
| 24 |
|
| 25 |
To get the path of directory holding application files:: |
| 26 |
|
| 27 |
>>> from plyer import storagepath |
| 28 |
>>> storagepath.get_application_dir() |
| 29 |
|
| 30 |
''' |
| 31 |
|
| 32 |
|
| 33 |
class StoragePath: |
| 34 |
''' |
| 35 |
StoragePath facade. |
| 36 |
''' |
| 37 |
|
| 38 |
def get_home_dir(self): |
| 39 |
''' |
| 40 |
Get the path of home directory of current user. |
| 41 |
''' |
| 42 |
return self._get_home_dir() |
| 43 |
|
| 44 |
def get_external_storage_dir(self): |
| 45 |
''' |
| 46 |
Get the path of primary shared or external storage directory. |
| 47 |
''' |
| 48 |
return self._get_external_storage_dir() |
| 49 |
|
| 50 |
def get_sdcard_dir(self): |
| 51 |
''' |
| 52 |
Get the path of external SD card. |
| 53 |
|
| 54 |
.. versionadded:: 1.4.0 |
| 55 |
''' |
| 56 |
return self._get_sdcard_dir() |
| 57 |
|
| 58 |
def get_root_dir(self): |
| 59 |
''' |
| 60 |
Get the path of root of the "system" partition holding the core OS. |
| 61 |
''' |
| 62 |
return self._get_root_dir() |
| 63 |
|
| 64 |
def get_documents_dir(self): |
| 65 |
''' |
| 66 |
Get the path of standard directory in which to place documents that |
| 67 |
have been created by the user. |
| 68 |
''' |
| 69 |
return self._get_documents_dir() |
| 70 |
|
| 71 |
def get_downloads_dir(self): |
| 72 |
''' |
| 73 |
Get the path of standard directory in which to place files that have |
| 74 |
been downloaded by the user. |
| 75 |
''' |
| 76 |
return self._get_downloads_dir() |
| 77 |
|
| 78 |
def get_videos_dir(self): |
| 79 |
''' |
| 80 |
Get the path of standard directory in which to place videos that are |
| 81 |
available to the user. |
| 82 |
''' |
| 83 |
return self._get_videos_dir() |
| 84 |
|
| 85 |
def get_music_dir(self): |
| 86 |
''' |
| 87 |
Get the path of standard directory in which to place any audio files |
| 88 |
that should be in the regular list of music for the user. |
| 89 |
''' |
| 90 |
return self._get_music_dir() |
| 91 |
|
| 92 |
def get_pictures_dir(self): |
| 93 |
''' |
| 94 |
Standard directory in which to place pictures that are available to |
| 95 |
the user. |
| 96 |
''' |
| 97 |
return self._get_pictures_dir() |
| 98 |
|
| 99 |
def get_application_dir(self): |
| 100 |
''' |
| 101 |
Get the path of the directory holding application files. |
| 102 |
''' |
| 103 |
return self._get_application_dir() |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
def _get_home_dir(self): |
| 108 |
raise NotImplementedError() |
| 109 |
|
| 110 |
def _get_external_storage_dir(self): |
| 111 |
raise NotImplementedError() |
| 112 |
|
| 113 |
def _get_sdcard_dir(self): |
| 114 |
raise NotImplementedError() |
| 115 |
|
| 116 |
def _get_root_dir(self): |
| 117 |
raise NotImplementedError() |
| 118 |
|
| 119 |
def _get_documents_dir(self): |
| 120 |
raise NotImplementedError() |
| 121 |
|
| 122 |
def _get_downloads_dir(self): |
| 123 |
raise NotImplementedError() |
| 124 |
|
| 125 |
def _get_videos_dir(self): |
| 126 |
raise NotImplementedError() |
| 127 |
|
| 128 |
def _get_music_dir(self): |
| 129 |
raise NotImplementedError() |
| 130 |
|
| 131 |
def _get_pictures_dir(self): |
| 132 |
raise NotImplementedError() |
| 133 |
|
| 134 |
def _get_application_dir(self): |
| 135 |
raise NotImplementedError() |