Updated again.

This commit is contained in:
Jeremy Fincher 2004-02-06 04:14:37 +00:00
parent 92a7ae1028
commit dce0378a8c

View File

@ -18,6 +18,7 @@ class IrcUser:
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
IrcChannel = IrcUser
UserCapabilitySet = list UserCapabilitySet = list
CapabilitySet = list CapabilitySet = list
@ -28,46 +29,51 @@ def write(fd, s):
if __name__ == '__main__': 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. try:
fd = file(userFile) # Users.conf.
s = fd.read().strip() fd = file(userFile)
(_, L) = eval(s, locals(), globals()) s = fd.read().strip()
fd = file(userFile, 'w') (_, L) = eval(s, locals(), globals())
for (i, u) in enumerate(L): fd = file(userFile, 'w')
if i == 0 or u is None: for (i, u) in enumerate(L):
continue if i == 0 or u is None:
write(fd, 'user %s' % i) continue
write(fd, ' name %s' % u.name) write(fd, 'user %s' % i)
write(fd, ' ignore %s' % u.ignore) write(fd, ' name %s' % u.name)
write(fd, ' secure %s' % u.secure) write(fd, ' ignore %s' % u.ignore)
write(fd, ' hashed %s' % u.hashed) write(fd, ' secure %s' % u.secure)
write(fd, ' password %s' % u.password) write(fd, ' hashed %s' % u.hashed)
for capability in u.capabilities: write(fd, ' password %s' % u.password)
try: for capability in u.capabilities:
(channel, capability) = rsplit(capability, '.', 1) try:
capability = ','.join(channel, capability) (channel, capability) = rsplit(capability, '.', 1)
except ValueError: capability = ','.join([channel, capability])
pass except ValueError:
write(fd, ' capability %s' % capability) pass
for hostmask in u.hostmasks: write(fd, ' capability %s' % capability)
write(fd, ' hostmask %s' % hostmask) for hostmask in u.hostmasks:
write(fd, '') write(fd, ' hostmask %s' % hostmask)
fd.close() write(fd, '')
fd.close()
# Channels.conf.
fd = file(channelFile)
s = fd.read().strip()
d = eval(s, locals(), globals())
fd = file(channelFile, 'w')
for (name, c) in d.iteritems():
write(fd, 'channel %s' % name)
write(fd, ' defaultAllow %s' % c.defaultAllow)
write(fd, ' lobotomized %s' % c.lobotomized)
for capability in c.capabilities:
write(fd, ' capability %s' % capability)
for ban in c.bans:
write(fd, ' ban %s' % ban)
for ignore in c.ignores:
write(fd, ' ignore %s' % ignore)
write(fd, '')
# Channels.conf.
fd = file(channelFile)
s = fd.read().strip()
d = eval(s, locals(), globals())
fd = file(channelFile, 'w')
for (name, c) in d.iteritems():
write(fd, 'channel %s' % name)
write(fd, ' defaultAllow %s' % c.defaultAllow)
write(fd, ' lobotomized %s' % c.lobotomized)
for capability in c.capabilities:
write(fd, ' capability %s' % capability)
for ban in c.bans:
write(fd, ' ban %s' % ban)
for ignore in c.ignores:
write(fd, ' ignore %s' % ignore)
write(fd, '')
except Exception, e:
print 'Exception raised, restoring backups.'
shutil.copy(userFile + '.bak', userFile)
shutil.copy(channelFile + '.bak', channelFile)
raise