mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Converted ChannelsDictionary to use a PersistentDictionary.
This commit is contained in:
parent
7d960ca4c6
commit
44227181b7
13
src/ircdb.py
13
src/ircdb.py
@ -41,6 +41,7 @@ import debug
|
|||||||
import utils
|
import utils
|
||||||
import world
|
import world
|
||||||
import ircutils
|
import ircutils
|
||||||
|
from structures import PersistentDictionary
|
||||||
|
|
||||||
def fromChannelCapability(capability):
|
def fromChannelCapability(capability):
|
||||||
"""Returns a (channel, capability) tuple from a channel capability."""
|
"""Returns a (channel, capability) tuple from a channel capability."""
|
||||||
@ -488,14 +489,8 @@ class UsersDB(object):
|
|||||||
class ChannelsDictionary(object):
|
class ChannelsDictionary(object):
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
if os.path.exists(filename):
|
|
||||||
fd = file(filename, 'r')
|
|
||||||
s = fd.read()
|
|
||||||
fd.close()
|
|
||||||
Set = sets.Set
|
Set = sets.Set
|
||||||
self.dict = eval(_normalize(s))
|
self.dict = PersistentDictionary(filename, globals(), locals())
|
||||||
else:
|
|
||||||
self.dict = {}
|
|
||||||
|
|
||||||
def getChannel(self, channel):
|
def getChannel(self, channel):
|
||||||
"""Returns an IrcChannel object for the given channel."""
|
"""Returns an IrcChannel object for the given channel."""
|
||||||
@ -514,9 +509,7 @@ class ChannelsDictionary(object):
|
|||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
"""Flushes the channel database to its file."""
|
"""Flushes the channel database to its file."""
|
||||||
fd = file(self.filename, 'w')
|
self.dict.flush()
|
||||||
fd.write(repr(self.dict))
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
"""Reloads the channel database from its file."""
|
"""Reloads the channel database from its file."""
|
||||||
|
Loading…
Reference in New Issue
Block a user