scripts/fix_duplicate_shorturls.py
author Tero Marttila <terom@fixme.fi>
Wed, 03 Jun 2009 18:37:12 +0300
branchold-taggr
changeset 37 5df1a18df815
parent 22 72696ca68c34
permissions -rw-r--r--
Old taggr code, never finished
from lib import shorturl

db = shorturl.DB(read_only=False)

ids = dict()

newid = db.db['_id']

for key in db.db.keys() :
    if key.startswith('_') :
        continue

    if len(key) == 1 :
        print "key %s is too short!?" % key
        del db.db[key]

        continue
    
    print "%s:" % key, 
    id = shorturl.key2int(key)

    if id in ids :
        newkey = shorturl.int2key(newid)
        newid += 1

        print "%d -> %s, -> %s" % (id, ids[id], newkey)

        db.db[newkey] = db.db[key]
        del db.db[key]
    else :
        print "ok"
        ids[id] = key