Return a directory path object with the given name. If the directory does not yet exist, it will be created. You can use it to manage files to e.g. store/retrieve database dumps across test sessions. .. versionadded:: 7.0 :param name: Must be a
(self, name: str)
| 120 | ) |
| 121 | |
| 122 | def mkdir(self, name: str) -> Path: |
| 123 | """Return a directory path object with the given name. |
| 124 | |
| 125 | If the directory does not yet exist, it will be created. You can use |
| 126 | it to manage files to e.g. store/retrieve database dumps across test |
| 127 | sessions. |
| 128 | |
| 129 | .. versionadded:: 7.0 |
| 130 | |
| 131 | :param name: |
| 132 | Must be a string not containing a ``/`` separator. |
| 133 | Make sure the name contains your plugin or application |
| 134 | identifiers to prevent clashes with other cache users. |
| 135 | """ |
| 136 | path = Path(name) |
| 137 | if len(path.parts) > 1: |
| 138 | raise ValueError("name is not allowed to contain path separators") |
| 139 | res = self._cachedir.joinpath(self._CACHE_PREFIX_DIRS, path) |
| 140 | res.mkdir(exist_ok=True, parents=True) |
| 141 | return res |
| 142 | |
| 143 | def _getvaluepath(self, key: str) -> Path: |
| 144 | return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key)) |