From 8f1a8beb76b18a061ef825b58daf2187d1c6dec7 Mon Sep 17 00:00:00 2001 From: "Andrew M. Farrell" Date: Wed, 5 Aug 2009 23:30:40 -0400 Subject: [PATCH] Added documentation on sset.py Signed-off-by: Andrew M. Farrell --- .gitignore | 2 ++ doc/index.rst | 1 + doc/module/wizard.sset.rst | 17 +++++++++++++++++ wizard/sset.py | 20 +++++++++++++++----- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 doc/module/wizard.sset.rst 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): -- 2.44.0