degal/commands.py
author Tero Marttila <terom@fixme.fi>
Fri, 05 Jun 2009 19:30:15 +0300
changeset 57 8d06e0283b88
parent 48 20355dd2e61a
permissions -rw-r--r--
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
"""
    Implementations of the core CLI commands
"""

import log, shorturl, folder

def main (dir='.', targets=()) :
    """
        Scan the given root dir for all images, and render updated ones
    """

    root_filter = {}
    
    # parse the targets into the hierarchial root_filter that we use
    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]
    
    # build the index
    log.title("Indexing %s...", dir)
    root = folder.Folder(dir)
    root.index(root_filter)
    log.up()
    
    # XXX: maintain shorturls stuff
    if False :
        log.title("Syncing ShortURLs...")
        shorturl.updateDB(root)
        log.up()

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

    return 0