detag.py
changeset 21 b75f9514e797
equal deleted inserted replaced
20:6c774496bb00 21:b75f9514e797
       
     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 from lib import tags, shorturl
       
    24 
       
    25 from sys import argv
       
    26 
       
    27 argv.pop(0)
       
    28 
       
    29 pos = argv.index("--")
       
    30 
       
    31 image_list = argv[:pos]
       
    32 tag_list = argv[pos+1:]
       
    33 
       
    34 tag_db = tags.TagDB(read_only=False)
       
    35 shorturl_db = shorturl.DB()
       
    36 
       
    37 img_codes = shorturl_db.shorturls_for(image_list)
       
    38 
       
    39 print "Have %d images and %d tags" % (len(img_codes), len(tag_list))
       
    40 
       
    41 for img_code in img_codes :
       
    42     for tag in tag_list :
       
    43         tag_db.tag(img_code, tag)
       
    44 
       
    45 tag_db.close()
       
    46