3 class ISerializedSet(object):
5 raise NotImplementedError
7 class SerializedSet(ISerializedSet):
8 """This set also records itself to a file, so that it
9 is persisted over multiple sessions."""
10 def __init__(self, file):
12 if os.path.isfile(file):
13 for line in open(file, "r"):
14 self.set.add(line.rstrip())
15 self.file = open(file, "a")
16 def __contains__(self, name):
17 return name in self.set
20 self.file.write(name + "\n")
23 class DummySerializedSet(ISerializedSet):
24 """Dummy object that doesn't actually cache anything and
25 claims that everything needs to be done"""
26 def __contains__(self, name):