author | Tero Marttila <terom@fixme.fi> |
Wed, 03 Jun 2009 19:40:35 +0300 | |
branch | use-distutils |
changeset 47 | 189f331c7960 |
parent 45 | 69eb5a4678a4 |
child 48 | 20355dd2e61a |
permissions | -rwxr-xr-x |
24 | 1 |
#!/usr/bin/env python2.5 |
1 | 2 |
# |
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 | 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 | 8 |
|
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 | 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 | 13 |
root_filter = {} |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
24
diff
changeset
|
14 |
|
1 | 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] = {} |
|
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 | 22 |
f = f[path_part] |
28 | 23 |
|
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 | 26 |
root.index(root_filter) |
28 | 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 | 33 |
|
34 |
log.title("Rendering updated dirs...") |
|
1 | 35 |
root.render() |
28 | 36 |
log.up() |
1 | 37 |
|
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) |