From 12ee483f7a484279a6a00e0de38ddbcb39c8bb89 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 11 Aug 2004 05:48:55 +0000 Subject: [PATCH] Slight bugfixes; returning from a remove is unpossible. --- src/dbi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dbi.py b/src/dbi.py index f2acc5f27..4643d02fd 100644 --- a/src/dbi.py +++ b/src/dbi.py @@ -40,6 +40,7 @@ import supybot.fix as fix import csv import math import sets +import random import supybot.cdb as cdb import supybot.utils as utils @@ -251,7 +252,7 @@ class CdbMapping(MappingInterface): class DB(object): - Mapping = None + Mapping = 'flat' # This is a good, sane default. Record = None def __init__(self, filename, Mapping=None, Record=None): if Record is not None: @@ -280,8 +281,7 @@ class DB(object): return self.map.add(s) def remove(self, id): - s = self.map.remove(id) - return self._newRecord(id, s) + self.map.remove(id) def __iter__(self): for (id, s) in self.map: @@ -293,6 +293,9 @@ class DB(object): if p(record): yield record + def random(self): + return random.choice(self) + def flush(self): self.map.flush()