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
24
001f52cd057e tagging/untagging should now work fully in taggr
terom
parents: 12
diff changeset
     1
#!/usr/bin/env python2.5
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
     2
#
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
     3
# DeGAL - A pretty simple web image gallery
47
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
     4
# Copyright 2008 Tero Marttila
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
     5
#
47
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
     6
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
     7
from degal import folder, shorturl, log
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
     8
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
     9
import os.path, os
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    10
from optparse import OptionParser
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    11
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    12
def main (dir='.', targets=()) :
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    13
    root_filter = {}
27
301d738b1181 fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents: 24
diff changeset
    14
    
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    15
    for target in targets :
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    16
        f = root_filter
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    17
        for path_part in target.split('/') :
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    18
            if path_part :
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    19
                if path_part not in f :
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    20
                    f[path_part] = {}
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    21
                    
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    22
                f = f[path_part]
28
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    23
    
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    24
    log.title("Indexing %s...", dir)
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    25
    root = folder.Folder(dir)
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    26
    root.index(root_filter)
28
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    27
    log.up()
47
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
    28
    
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
    29
    if False :
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
    30
        log.title("Syncing ShortURLs...")
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
    31
        shorturl.updateDB(root)
189f331c7960 fix template to use pkg_resources, bin/degal does now run
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
    32
        log.up()
28
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    33
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    34
    log.title("Rendering updated dirs...")
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    35
    root.render()
28
70b6c13d084f fancy new log format
terom
parents: 27
diff changeset
    36
    log.up()
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    37
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    38
if __name__ == '__main__' :
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    39
    parser = OptionParser(usage="usage: %prog [options] ... [target ...]")
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    40
    
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    41
    parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".")
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    42
    
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    43
    options, filter_targets = parser.parse_args()
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    44
    
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 11
diff changeset
    45
    main(options.dir, filter_targets)