author | Tero Marttila <terom@fixme.fi> |
Wed, 03 Jun 2009 18:36:17 +0300 | |
changeset 35 | 73aef1124b67 |
parent 21 | b75f9514e797 |
permissions | -rwxr-xr-x |
21
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
1 |
#!/usr/bin/env python2.4 |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
2 |
# |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
3 |
# DeGAL - A pretty simple web image gallery |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
4 |
# Copyright (C) 2007 Tero Marttila |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
5 |
# http://marttila.de/~terom/degal/ |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
6 |
# |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
7 |
# This program is free software; you can redistribute it and/or modify |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
8 |
# it under the terms of the GNU General Public License as published by |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
9 |
# the Free Software Foundation; either version 2 of the License, or |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
10 |
# (at your option) any later version. |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
11 |
# |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
12 |
# This program is distributed in the hope that it will be useful, |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
15 |
# GNU General Public License for more details. |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
16 |
# |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU General Public License |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
18 |
# along with this program; if not, write to the |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
19 |
# Free Software Foundation, Inc., |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
20 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
21 |
# |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
22 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
23 |
from lib import tags, shorturl |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
24 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
25 |
from sys import argv |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
26 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
27 |
argv.pop(0) |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
28 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
29 |
pos = argv.index("--") |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
30 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
31 |
image_list = argv[:pos] |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
32 |
tag_list = argv[pos+1:] |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
33 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
34 |
tag_db = tags.TagDB(read_only=False) |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
35 |
shorturl_db = shorturl.DB() |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
36 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
37 |
img_codes = shorturl_db.shorturls_for(image_list) |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
38 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
39 |
print "Have %d images and %d tags" % (len(img_codes), len(tag_list)) |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
40 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
41 |
for img_code in img_codes : |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
42 |
for tag in tag_list : |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
43 |
tag_db.tag(img_code, tag) |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
44 |
|
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
45 |
tag_db.close() |
b75f9514e797
slipping in detag.py in the hopes that nobody will notice it before it's gone again...
terom
parents:
diff
changeset
|
46 |