degal/commands.py
branchuse-distutils
changeset 48 20355dd2e61a
equal deleted inserted replaced
47:189f331c7960 48:20355dd2e61a
       
     1 """
       
     2     Implementations of the core CLI commands
       
     3 """
       
     4 
       
     5 import log, shorturl, folder
       
     6 
       
     7 def main (dir='.', targets=()) :
       
     8     """
       
     9         Scan the given root dir for all images, and render updated ones
       
    10     """
       
    11 
       
    12     root_filter = {}
       
    13     
       
    14     # parse the targets into the hierarchial root_filter that we use
       
    15     for target in targets :
       
    16         f = root_filter
       
    17         for path_part in target.split('/') :
       
    18             if path_part :
       
    19                 if path_part not in f :
       
    20                     f[path_part] = {}
       
    21                     
       
    22                 f = f[path_part]
       
    23     
       
    24     # build the index
       
    25     log.title("Indexing %s...", dir)
       
    26     root = folder.Folder(dir)
       
    27     root.index(root_filter)
       
    28     log.up()
       
    29     
       
    30     # XXX: maintain shorturls stuff
       
    31     if False :
       
    32         log.title("Syncing ShortURLs...")
       
    33         shorturl.updateDB(root)
       
    34         log.up()
       
    35 
       
    36     # render output
       
    37     log.title("Rendering updated dirs...")
       
    38     root.render()
       
    39     log.up()
       
    40 
       
    41     return 0
       
    42