[Docstring-checkins] CVS: dps/dps/writers __init__.py,1.2,1.3
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2002-02-12 02:13:41
|
Update of /cvsroot/docstring/dps/dps/writers In directory usw-pr-cvs1:/tmp/cvs-serv29995/dps/dps/writers Modified Files: __init__.py Log Message: rearranged & improved Index: __init__.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/writers/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 7 Feb 2002 01:58:29 -0000 1.2 --- __init__.py 12 Feb 2002 02:13:38 -0000 1.3 *************** *** 27,41 **** """ def write(self, document, destination): self.document = document self.destination = destination self.transform() ! self.record(self.document, self.destination) def transform(self): ! """Override to run document tree transforms.""" raise NotImplementedError('subclass must override this method') ! def record(self, document, destination): """Override to record `document` to `destination`.""" raise NotImplementedError('subclass must override this method') --- 27,63 ---- """ + document = None + """The document to write.""" + + destination = None + """Where to write the document.""" + + transforms = () + """Ordered list of transform classes (each with a ``transform()`` method). + Populated by subclasses. `Writer.transform()` instantiates & runs them.""" + + def __init__(self): + """Initialize the Writer instance.""" + + self.transforms = list(self.transforms) + """Instance copy of `Writer.transforms`; may be modified by client.""" + def write(self, document, destination): self.document = document self.destination = destination self.transform() ! self.translate() ! self.record() def transform(self): ! """Run all of the transforms defined for this Writer.""" ! for xclass in self.transforms: ! xclass().transform(self.document) ! ! def translate(self): ! """Override to do final document tree translation.""" raise NotImplementedError('subclass must override this method') ! def record(self): """Override to record `document` to `destination`.""" raise NotImplementedError('subclass must override this method') *************** *** 59,63 **** else: sys.stdout.write(output) - pass --- 81,84 ---- |