move .config from filesystem to gallery/folder/image, rename degal_dir to app_dir
"""
Top-level gallery state
"""
import filesystem, folder
from utils import lazy_load
class Gallery (filesystem.Root, folder.Folder) :
"""
A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff
"""
def _init_config (self) :
"""
Keep using our given .config
"""
return self.config
def __init__ (self, path, config) :
"""
Build a Gallery rooted at the given filesystem path, and using the given user configuration.
XXX: replace path with config.gallery_path?
"""
# store config for access by Folder.__init__
self.config = config
# cooperative
super(Gallery, self).__init__(path)
@property
def _app_dir (self) :
"""
The dir containing our application data.
"""
return self.subdir('.degal')
@lazy_load
def app_dir (self) :
"""
The dir containing our application data.
It will be created if it does not exist.
"""
return self.subdir('.degal', create=True)
@lazy_load
def stylesheet (self) :
"""
The stylesheet file.
It will be copied from internal resources if it does not exist.
"""
stylesheet = self.app_dir.subfile('style.css')
if not stylesheet.exists() :
# load the resources dir
from resources import STATIC_DIR
# copy it from the static resource file
stylesheet.copy_from(STATIC_DIR.subfile('style.css'))
# elif stylesheet-is-older-than-resources-one: warn
return stylesheet