bin/degal
branchuse-distutils
changeset 48 20355dd2e61a
parent 47 189f331c7960
equal deleted inserted replaced
47:189f331c7960 48:20355dd2e61a
     2 #
     2 #
     3 # DeGAL - A pretty simple web image gallery
     3 # DeGAL - A pretty simple web image gallery
     4 # Copyright 2008 Tero Marttila
     4 # Copyright 2008 Tero Marttila
     5 #
     5 #
     6 
     6 
     7 from degal import folder, shorturl, log
     7 # import package
     8 
     8 import degal.main
     9 import os.path, os
       
    10 from optparse import OptionParser
       
    11 
       
    12 def main (dir='.', targets=()) :
       
    13     root_filter = {}
       
    14     
       
    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     log.title("Indexing %s...", dir)
       
    25     root = folder.Folder(dir)
       
    26     root.index(root_filter)
       
    27     log.up()
       
    28     
       
    29     if False :
       
    30         log.title("Syncing ShortURLs...")
       
    31         shorturl.updateDB(root)
       
    32         log.up()
       
    33 
       
    34     log.title("Rendering updated dirs...")
       
    35     root.render()
       
    36     log.up()
       
    37 
     9 
    38 if __name__ == '__main__' :
    10 if __name__ == '__main__' :
    39     parser = OptionParser(usage="usage: %prog [options] ... [target ...]")
    11     import sys
    40     
    12     
    41     parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".")
    13     # run entrypoint with command arguments, and exit with returned error code
    42     
    14     sys.exit(degal.main.main(sys.argv))
    43     options, filter_targets = parser.parse_args()
    15 
    44     
       
    45     main(options.dir, filter_targets)