def _cache_dir_for_dir(dir): # Consider using md5 for path name here, like thumbnail spec from zim.config import XDG_CACHE_HOME if os.name == 'nt': path = 'notebook-' + dir.path.replace('\\', '_').replace(':', '').strip('_') else: path = 'notebook-' + dir.path.replace('/', '_').strip('_') return XDG_CACHE_HOME.subdir(('zim', path))
from gi.repository import Gtk from gi.repository import GdkPixbuf import logging logger = logging.getLogger('zim.plugins.attachmentbrowser') import zim from zim.config import XDG_CACHE_HOME from zim.gui.widgets import rotate_pixbuf from zim.newfs import LocalFile, LocalFolder LOCAL_THUMB_STORAGE_NORMAL = XDG_CACHE_HOME.subdir('thumbnails/normal') LOCAL_THUMB_STORAGE_LARGE = XDG_CACHE_HOME.subdir('thumbnails/large') LOCAL_THUMB_STORAGE_FAIL = XDG_CACHE_HOME.subdir('thumbnails/fail/zim-%s' % zim.__version__) ## XXX zim.fs --> zim.newfs LOCAL_THUMB_STORAGE_NORMAL = LocalFolder(LOCAL_THUMB_STORAGE_NORMAL.path) LOCAL_THUMB_STORAGE_LARGE = LocalFolder(LOCAL_THUMB_STORAGE_LARGE.path) LOCAL_THUMB_STORAGE_FAIL = LocalFolder(LOCAL_THUMB_STORAGE_FAIL.path) ## THUMB_SIZE_NORMAL = 128 THUMB_SIZE_LARGE = 256 class ThumbnailCreatorFailure(ValueError):
def _cache_dir(self, dir): from zim.config import XDG_CACHE_HOME path = 'notebook-' + dir.path.replace('/', '_').strip('_') return XDG_CACHE_HOME.subdir(('zim', path))