From: Andrew M. Farrell Date: Thu, 6 Aug 2009 03:30:40 +0000 (-0400) Subject: Added documentation on sset.py X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/commitdiff_plain/8f1a8beb76b18a061ef825b58daf2187d1c6dec7 Added documentation on sset.py Signed-off-by: Andrew M. Farrell --- diff --git a/.gitignore b/.gitignore index 0d20b64..50d7a76 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pyc +*.swp +*~ diff --git a/doc/index.rst b/doc/index.rst index 27632e7..a5ba181 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -66,6 +66,7 @@ Modules module/wizard.install module/wizard.shell module/wizard.util + module/wizard.sset Indices and tables ------------------ diff --git a/doc/module/wizard.sset.rst b/doc/module/wizard.sset.rst new file mode 100644 index 0000000..1293ca9 --- /dev/null +++ b/doc/module/wizard.sset.rst @@ -0,0 +1,17 @@ +:mod:`wizard.sset` +=================== + +.. automodule:: wizard.sset + +Classes +------- +.. autoclass:: make + :members: +.. autoclass:: ISerializedSet + :members: +.. autoclass:: SerializedSet + :members: + :inherited-members: +.. autoclass:: DummySerializedSet + :members: + :inherited-members: diff --git a/wizard/sset.py b/wizard/sset.py index e6a4527..0edfd27 100644 --- a/wizard/sset.py +++ b/wizard/sset.py @@ -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() 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): @@ -27,8 +35,10 @@ class SerializedSet(ISerializedSet): 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):