terom@64: """ terom@64: Top-level gallery state terom@64: """ terom@64: terom@112: import filesystem, folder terom@64: terom@64: from utils import lazy_load terom@64: terom@64: class Gallery (filesystem.Root, folder.Folder) : terom@64: """ terom@64: A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff terom@64: """ terom@64: terom@64: def __init__ (self, path, config) : terom@64: """ terom@64: Build a Gallery rooted at the given filesystem path, and using the given user configuration. terom@64: terom@64: XXX: replace path with config.gallery_path? terom@64: """ terom@64: terom@64: super(Gallery, self).__init__(path, config) terom@64: terom@118: @property terom@118: def _degal_dir (self) : terom@118: """ terom@118: The dir containing the degal configuration. terom@118: """ terom@118: terom@118: return self.subdir('.degal') terom@118: terom@64: @lazy_load terom@64: def degal_dir (self) : terom@64: """ terom@64: The dir containing the degal configuration. terom@64: terom@64: It will be created if it does not exist. terom@64: """ terom@64: terom@73: return self.subdir('.degal', create=True) terom@73: terom@64: @lazy_load terom@64: def stylesheet (self) : terom@64: """ terom@64: The stylesheet file. terom@64: terom@64: It will be copied from internal resources if it does not exist. terom@64: """ terom@64: terom@64: stylesheet = self.degal_dir.subfile('style.css') terom@64: terom@82: if not stylesheet.exists() : terom@112: # load the resources dir terom@129: from resources import STATIC_DIR terom@112: terom@112: # copy it from the static resource file terom@112: stylesheet.copy_from(STATIC_DIR.subfile('style.css')) terom@64: terom@64: return stylesheet terom@64: