Updated not to depend on the old ircdb.

This commit is contained in:
Jeremy Fincher 2004-02-06 03:59:17 +00:00
parent 21ef041a58
commit 92a7ae1028

View File

@ -4,23 +4,22 @@ import os
import sys import sys
import shutil import shutil
if len(sys.argv) < 3: if len(sys.argv) != 3:
sys.stderr.write('Usage: %s <users file> <channels file>\n') sys.stderr.write('Usage: %s <users file> <channels file>\n')
sys.exit(-1) sys.exit(-1)
(userFile, channelFile) = sys.argv[1:]
import supybot import supybot
import fix
import conf (userFile, channelFile) = sys.argv[1:]
conf.supybot.directories.conf.setValue('.')
conf.supybot.databases.users.filename.setValue(userFile)
conf.supybot.databases.channels.filename.setValue(channelFile)
import log class IrcUser:
conf.supybot.log.stdout.setValue(False) def __init__(self, **kwargs):
self.__dict__.update(kwargs)
import ircdb UserCapabilitySet = list
CapabilitySet = list
def write(fd, s): def write(fd, s):
fd.write(s) fd.write(s)
@ -30,9 +29,12 @@ if __name__ == '__main__':
shutil.copy(userFile, userFile + '.bak') shutil.copy(userFile, userFile + '.bak')
shutil.copy(channelFile, channelFile + '.bak') shutil.copy(channelFile, channelFile + '.bak')
# Users.conf. # Users.conf.
fd = file(userFile)
s = fd.read().strip()
(_, L) = eval(s, locals(), globals())
fd = file(userFile, 'w') fd = file(userFile, 'w')
for (i, u) in enumerate(ircdb.users.users): for (i, u) in enumerate(L):
if u is None: if i == 0 or u is None:
continue continue
write(fd, 'user %s' % i) write(fd, 'user %s' % i)
write(fd, ' name %s' % u.name) write(fd, ' name %s' % u.name)
@ -53,8 +55,11 @@ if __name__ == '__main__':
fd.close() fd.close()
# Channels.conf. # Channels.conf.
fd = file(channelFile)
s = fd.read().strip()
d = eval(s, locals(), globals())
fd = file(channelFile, 'w') fd = file(channelFile, 'w')
for (name, c) in ircdb.channels.iteritems(): for (name, c) in d.iteritems():
write(fd, 'channel %s' % name) write(fd, 'channel %s' % name)
write(fd, ' defaultAllow %s' % c.defaultAllow) write(fd, ' defaultAllow %s' % c.defaultAllow)
write(fd, ' lobotomized %s' % c.lobotomized) write(fd, ' lobotomized %s' % c.lobotomized)