#!/usr/bin/env python2

# Just place this file in /var/lib/janchor (or wherever 'sources' and
# 'registrations' files are placed) and run it. Then check what's in
# 'sources.sql' and 'registrations.sql'.

import anydbm

deftimeout=30

sources=[]

db=anydbm.open('sources')
f=open('sources.sql', 'w')
for key in db:
    sources.append(key)
    f.write("INSERT INTO addressess (name,url,time) VALUES ('%s', '%s', %d);\n" % (key, db[key], deftimeout))
db.close()
f.close()

db=anydbm.open('registrations')
f=open('registrations.sql', 'w')
for key in db:
    for i in db[key].split("'"):
        if i in sources:
            f.write("INSERT INTO subs (jid, namerss) VALUES ('%s', '%s');\n" % (
                    key, i))
db.close()
f.close()

