author | terom |
Fri, 21 Dec 2007 20:45:03 +0000 | |
changeset 13 | c229bcb1de41 |
parent 12 | c2d8e9a754a1 |
child 24 | 001f52cd057e |
permissions | -rwxr-xr-x |
1 | 1 |
#!/usr/bin/env python2.4 |
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 |
|
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
|
26 |
from lib import folder, shorturl |
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 = {} |
30 |
||
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] |
39 |
||
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
|
40 |
root = folder.Folder(dir) |
1 | 41 |
root.index(root_filter) |
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
|
42 |
shorturl.updateDB(root) |
1 | 43 |
root.render() |
44 |
||
45 |
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
|
46 |
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
|
47 |
|
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
|
48 |
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
|
49 |
|
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
|
50 |
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
|
51 |
|
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
|
52 |
main(options.dir, filter_targets) |