import locale as _locale
import logging as _logging
import os.path as _os_path
+import os as _os
import pickle as _pickle
import sys as _sys
import time as _time
def _get_cache_path(self):
"Get the cache file path"
- if _xdg_basedirectory:
+
+ # Some versions of pyxdg don't have save_cache_path (0.20 and older)
+ # See: https://bugs.freedesktop.org/show_bug.cgi?id=26458
+ if _xdg_basedirectory and 'save_cache_path' in dir(_xdg_basedirectory):
path = _xdg_basedirectory.save_cache_path('')
else:
self._log_xdg_import_error()
path = _os_path.expanduser(_os_path.join('~', '.cache'))
+ if not _os_path.isdir(path):
+ _os.makedirs(path)
return _os_path.join(path, 'mutt-ldap.json')
def _log_xdg_import_error(self):
global _xdg_import_error
if _xdg_import_error:
- LOG.error(u'could not import xdg.BaseDirectory')
- LOG.error(_xdg_import_error)
+ LOG.warning(u'could not import xdg.BaseDirectory '
+ u'or lacking necessary support')
+ LOG.warning(_xdg_import_error)
_xdg_import_error = None
CONFIG.set('cache', 'enable', 'yes') # enable caching by default
CONFIG.set('cache', 'path', '') # cache results here, defaults to XDG
CONFIG.set('cache', 'fields', '') # fields to cache (if empty, setup in the main block)
-CONFIG.set('cache', 'longevity-days', '14') # TODO: cache results for 14 days by default
+CONFIG.set('cache', 'longevity-days', '14') # Days before cache entries are invalidated
CONFIG.add_section('system')
# HACK: Python 2.x support, see http://bugs.python.org/issue13329#msg147475
CONFIG.set('system', 'output-encoding', '') # match .muttrc's $charset