Handled the case of an empty file (which apparently can crop up sometimes in unclean exits).

This commit is contained in:
Jeremy Fincher 2004-10-19 16:41:52 +00:00
parent dec94a2ecf
commit 3f16003371

View File

@ -76,10 +76,12 @@ class PickleBayesDB(plugins.DbiChannelDB):
self.filename = filename
self.nickFilename = self.filename.replace('pickle', 'nick.pickle')
self.bayes = reverend.thomas.Bayes(tokenize)
if os.path.exists(self.filename):
if os.path.exists(self.filename) and \
os.path.getsize(self.filename):
self.bayes.load(self.filename)
self.nickBayes = reverend.thomas.Bayes(tokenize)
if os.path.exists(self.nickFilename):
if os.path.exists(self.nickFilename) and \
os.path.getsize(self.nickFilename):
self.nickBayes.load(self.nickFilename)
def close(self):