degal/gallery.py
changeset 64 4ebd563214d2
child 73 8897352630a5
equal deleted inserted replaced
63:0db16d6b3617 64:4ebd563214d2
       
     1 """
       
     2     Top-level gallery state
       
     3 """
       
     4 
       
     5 import filesystem, folder, resources
       
     6 
       
     7 from utils import lazy_load
       
     8 
       
     9 class Gallery (filesystem.Root, folder.Folder) :
       
    10     """
       
    11         A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff
       
    12     """
       
    13 
       
    14     def __init__ (self, path, config) :
       
    15         """
       
    16             Build a Gallery rooted at the given filesystem path, and using the given user configuration.
       
    17 
       
    18             XXX: replace path with config.gallery_path?
       
    19         """
       
    20 
       
    21         super(Gallery, self).__init__(path, config)
       
    22 
       
    23     @lazy_load
       
    24     def degal_dir (self) :
       
    25         """
       
    26             The dir containing the degal configuration.
       
    27 
       
    28             It will be created if it does not exist.
       
    29         """
       
    30 
       
    31         return self.subdir('degal', create=True)
       
    32 
       
    33     @lazy_load
       
    34     def stylesheet (self) :
       
    35         """
       
    36             The stylesheet file.
       
    37 
       
    38             It will be copied from internal resources if it does not exist.
       
    39         """
       
    40 
       
    41         stylesheet = self.degal_dir.subfile('style.css')
       
    42         
       
    43         if not stylesheet :
       
    44             # copy it from resources
       
    45             stylesheet.copy_from(resources.STATIC_DIR.subfile('style.css'))
       
    46 
       
    47         return stylesheet
       
    48