Return the XDG_CACHE_HOME, if it is defined and exists, else None. This is only for non-OS X posix (Linux,Unix,etc.) systems.
()
| 216 | |
| 217 | |
| 218 | def get_xdg_cache_dir(): |
| 219 | """Return the XDG_CACHE_HOME, if it is defined and exists, else None. |
| 220 | |
| 221 | This is only for non-OS X posix (Linux,Unix,etc.) systems. |
| 222 | """ |
| 223 | |
| 224 | env = os.environ |
| 225 | |
| 226 | if os.name == "posix": |
| 227 | # Linux, Unix, AIX, etc. |
| 228 | # use ~/.cache if empty OR not set |
| 229 | xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache') |
| 230 | if xdg and _writable_dir(xdg): |
| 231 | assert isinstance(xdg, str) |
| 232 | return xdg |
| 233 | |
| 234 | return None |
| 235 | |
| 236 | |
| 237 | def expand_path(s: str) -> str: |
no test coverage detected
searching dependent graphs…