]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/sset.py
Set admin e-mail address properly on MediaWiki >= 1.18.0
[wizard.git] / wizard / sset.py
index 22cc971858c54124c38d60804db0749d4dd2b1cd..b2364db98c5839fa49e78e0cbebadd7da9947491 100644 (file)
@@ -1,18 +1,26 @@
 import os.path
 
 def make(seen_file):
+    """
+    Return a :class:`SerialisedSet` if given any non-empty string.
+    If given an empty string, return a :class:`DummySerialisedSet`.
+    """
     if seen_file:
         return SerializedSet(seen_file)
     else:
-        return DummySerializedSet(seen_file)
+        return DummySerializedSet()
 
 class ISerializedSet(object):
-    def put(self, name):
+    """A unique unordered collection of strings."""
+    def add(self, name):
+        """Adds a value into the set."""
         raise NotImplementedError
 
 class SerializedSet(ISerializedSet):
-    """This set also records itself to a file, so that it
-    is persisted over multiple sessions."""
+    """
+    This set also records itself to a file, so that it
+    is persisted over multiple sessions.
+    """
     def __init__(self, file):
         self.set = set()
         if os.path.isfile(file):
@@ -22,14 +30,18 @@ class SerializedSet(ISerializedSet):
     def __contains__(self, name):
         return name in self.set
     def add(self, name):
+        """Adds a value into the set."""
         self.set.add(name)
         self.file.write(name + "\n")
         self.file.flush()
 
 class DummySerializedSet(ISerializedSet):
-    """Dummy object that doesn't actually cache anything and
-    claims that everything needs to be done"""
+    """
+    Dummy object that doesn't actually cache anything and
+    claims that everything needs to be done.
+    """
     def __contains__(self, name):
         return False
     def add(self, name):
+        """Doesn't do anything."""
         pass