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