author | terom |
Fri, 21 Dec 2007 21:19:01 +0000 | |
changeset 15 | 0fe851a29bc6 |
parent 14 | 4b5478da5850 |
child 18 | 46536daf9e04 |
permissions | -rw-r--r-- |
14
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
1 |
# DeGAL - A pretty simple web image gallery |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
2 |
# Copyright (C) 2007 Tero Marttila |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
3 |
# http://marttila.de/~terom/degal/ |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
4 |
# |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
5 |
# This program is free software; you can redistribute it and/or modify |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
6 |
# it under the terms of the GNU General Public License as published by |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
7 |
# the Free Software Foundation; either version 2 of the License, or |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
8 |
# (at your option) any later version. |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
9 |
# |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
10 |
# This program is distributed in the hope that it will be useful, |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
13 |
# GNU General Public License for more details. |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
14 |
# |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
15 |
# You should have received a copy of the GNU General Public License |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
16 |
# along with this program; if not, write to the |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
17 |
# Free Software Foundation, Inc., |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
18 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
19 |
# |
4b5478da5850
remove hanging utils.py in root, and add GPL license header to all .py files
terom
parents:
12
diff
changeset
|
20 |
|
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:
diff
changeset
|
21 |
import os.path |
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:
diff
changeset
|
22 |
|
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:
diff
changeset
|
23 |
def readFile (path) : |
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:
diff
changeset
|
24 |
fo = open(path, 'r') |
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:
diff
changeset
|
25 |
data = fo.read() |
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:
diff
changeset
|
26 |
fo.close() |
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:
diff
changeset
|
27 |
|
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:
diff
changeset
|
28 |
return data |
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:
diff
changeset
|
29 |
|
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:
diff
changeset
|
30 |
def readTitleDescr (path) : |
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:
diff
changeset
|
31 |
""" |
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:
diff
changeset
|
32 |
Read a title.txt or <imgname>.txt file |
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:
diff
changeset
|
33 |
""" |
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:
diff
changeset
|
34 |
|
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:
diff
changeset
|
35 |
if os.path.exists(path) : |
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:
diff
changeset
|
36 |
content = readFile(path) |
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:
diff
changeset
|
37 |
|
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:
diff
changeset
|
38 |
if '---' in content : |
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:
diff
changeset
|
39 |
title, descr = content.split('---', 1) |
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:
diff
changeset
|
40 |
else : |
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:
diff
changeset
|
41 |
title, descr = content, '' |
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:
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:
diff
changeset
|
43 |
return title.strip(), descr.strip() |
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:
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:
diff
changeset
|
45 |
return "", "" |
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:
diff
changeset
|
46 |
|
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:
diff
changeset
|
47 |
def url_join (*parts) : |
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:
diff
changeset
|
48 |
return '/'.join(parts) |
15
0fe851a29bc6
detool.py, meant to be a collection of utility operations, currently lets you move images and their html/thumb/preview files at the same time
terom
parents:
14
diff
changeset
|
49 |
|
0fe851a29bc6
detool.py, meant to be a collection of utility operations, currently lets you move images and their html/thumb/preview files at the same time
terom
parents:
14
diff
changeset
|
50 |
def path_join (*parts) : |
0fe851a29bc6
detool.py, meant to be a collection of utility operations, currently lets you move images and their html/thumb/preview files at the same time
terom
parents:
14
diff
changeset
|
51 |
return os.path.join(*[part for part in parts if part is not None]) |
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:
diff
changeset
|
52 |
|
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:
diff
changeset
|
53 |
from optparse import OptionParser |
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:
diff
changeset
|
54 |
|
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:
diff
changeset
|
55 |
def optparse (options) : |
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:
diff
changeset
|
56 |
parser = OptionParser() |
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:
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:
diff
changeset
|
58 |
|
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:
diff
changeset
|
59 |
parser.add_option |
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:
diff
changeset
|
60 |
|
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:
diff
changeset
|
61 |