author | Tero Marttila <terom@fixme.fi> |
Wed, 03 Jun 2009 18:59:46 +0300 | |
branch | use-distutils |
changeset 40 | 373392025533 |
parent 38 | degal@2e9fdb080ad6 |
permissions | -rwxr-xr-x |
24 | 1 |
#!/usr/bin/env python2.5 |
1 | 2 |
# |
3 |
# DeGAL - A pretty simple web image gallery |
|
4 |
# Copyright (C) 2007 Tero Marttila |
|
5 |
# http://marttila.de/~terom/degal/ |
|
6 |
# |
|
7 |
# This program is free software; you can redistribute it and/or modify |
|
8 |
# it under the terms of the GNU General Public License as published by |
|
9 |
# the Free Software Foundation; either version 2 of the License, or |
|
10 |
# (at your option) any later version. |
|
11 |
# |
|
12 |
# This program is distributed in the hope that it will be useful, |
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
# GNU General Public License for more details. |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License |
|
18 |
# along with this program; if not, write to the |
|
19 |
# Free Software Foundation, Inc., |
|
20 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
# |
|
22 |
||
23 |
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
|
24 |
from optparse import OptionParser |
1 | 25 |
|
28 | 26 |
from lib import folder, shorturl, log |
1 | 27 |
|
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
|
28 |
def main (dir='.', targets=()) : |
1 | 29 |
root_filter = {} |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
24
diff
changeset
|
30 |
|
1 | 31 |
for target in targets : |
32 |
f = root_filter |
|
33 |
for path_part in target.split('/') : |
|
34 |
if path_part : |
|
35 |
if path_part not in f : |
|
36 |
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
|
37 |
|
1 | 38 |
f = f[path_part] |
28 | 39 |
|
40 |
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
|
41 |
root = folder.Folder(dir) |
1 | 42 |
root.index(root_filter) |
28 | 43 |
log.up() |
44 |
||
45 |
log.title("Syncing ShortURLs...") |
|
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
|
46 |
shorturl.updateDB(root) |
28 | 47 |
log.up() |
48 |
||
49 |
log.title("Rendering updated dirs...") |
|
1 | 50 |
root.render() |
28 | 51 |
log.up() |
1 | 52 |
|
53 |
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
|
54 |
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
|
55 |
|
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
|
56 |
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
|
57 |
|
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
|
58 |
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
|
59 |
|
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
|
60 |
main(options.dir, filter_targets) |