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.
()
| 231 | |
| 232 | |
| 233 | def get_xdg_cache_dir(): |
| 234 | """Return the XDG_CACHE_HOME, if it is defined and exists, else None. |
| 235 | |
| 236 | This is only for non-OS X posix (Linux,Unix,etc.) systems. |
| 237 | """ |
| 238 | |
| 239 | env = os.environ |
| 240 | |
| 241 | if os.name == 'posix' and sys.platform != 'darwin': |
| 242 | # Linux, Unix, AIX, etc. |
| 243 | # use ~/.cache if empty OR not set |
| 244 | xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache') |
| 245 | if xdg and _writable_dir(xdg): |
| 246 | assert isinstance(xdg, str) |
| 247 | return xdg |
| 248 | |
| 249 | return None |
| 250 | |
| 251 | |
| 252 | @undoc |
no test coverage detected