bin/degal
author Tero Marttila <terom@fixme.fi>
Wed, 03 Jun 2009 19:40:35 +0300
branchuse-distutils
changeset 47 189f331c7960
parent 45 69eb5a4678a4
child 48 20355dd2e61a
permissions -rwxr-xr-x
fix template to use pkg_resources, bin/degal does now run
#!/usr/bin/env python2.5
#
# DeGAL - A pretty simple web image gallery
# Copyright 2008 Tero Marttila
#

from degal import folder, shorturl, log

import os.path, os
from optparse import OptionParser

def main (dir='.', targets=()) :
    root_filter = {}
    
    for target in targets :
        f = root_filter
        for path_part in target.split('/') :
            if path_part :
                if path_part not in f :
                    f[path_part] = {}
                    
                f = f[path_part]
    
    log.title("Indexing %s...", dir)
    root = folder.Folder(dir)
    root.index(root_filter)
    log.up()
    
    if False :
        log.title("Syncing ShortURLs...")
        shorturl.updateDB(root)
        log.up()

    log.title("Rendering updated dirs...")
    root.render()
    log.up()

if __name__ == '__main__' :
    parser = OptionParser(usage="usage: %prog [options] ... [target ...]")
    
    parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".")
    
    options, filter_targets = parser.parse_args()
    
    main(options.dir, filter_targets)