# Copyright (C) 2004 Nicolas Delon # All Rights Reserved # # This file is part of the Prelude program. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. import shelve MODE_READ = "r" MODE_RW = "w" MODE_TRUNC = "n" class DBM: def __init__(self, filename, mode): self.db = shelve.open(filename, mode) self.retrieved = { } for filename in self.db.keys(): self.retrieved[filename] = False def print_(self): for filename in self.db.keys(): print self.db[filename] def getRemainings(self): return filter(lambda f: not self.retrieved[f], self.db.keys()) def __setitem__(self, filename, file): self.db[filename] = file def __getitem__(self, filename): self.retrieved[filename] = True return self.db[filename] def __delitem__(self, filename): del self.db[filename] def getFiles(self): return self.db.keys() # FIXME