[Python-checkins] CVS: python/dist/src/Lib sgmllib.py,1.34,1.35
Fred L. Drake
fdrake@users.sourceforge.net
Thu, 19 Jul 2001 13:08:06 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv27408/Lib
Modified Files:
sgmllib.py
Log Message:
Added docstrings based on a patch by Evelyn Mitchell.
This closes SF patch #440153.
Index: sgmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** sgmllib.py 2001/07/16 18:30:35 1.34
--- sgmllib.py 2001/07/19 20:08:04 1.35
***************
*** 66,76 ****
class SGMLParser:
- # Interface -- initialize and reset this instance
def __init__(self, verbose=0):
self.verbose = verbose
self.reset()
- # Interface -- reset this instance. Loses all unprocessed data
def reset(self):
self.rawdata = ''
self.stack = []
--- 66,76 ----
class SGMLParser:
def __init__(self, verbose=0):
+ """Initialize and reset this instance."""
self.verbose = verbose
self.reset()
def reset(self):
+ """Reset this instance. Loses all unprocessed data."""
self.rawdata = ''
self.stack = []
***************
*** 79,100 ****
self.literal = 0
- # For derived classes only -- enter literal mode (CDATA) till EOF
def setnomoretags(self):
self.nomoretags = self.literal = 1
- # For derived classes only -- enter literal mode (CDATA)
def setliteral(self, *args):
self.literal = 1
- # Interface -- feed some data to the parser. Call this as
- # often as you want, with as little or as much text as you
- # want (may include '\n'). (This just saves the text, all the
- # processing is done by goahead().)
def feed(self, data):
self.rawdata = self.rawdata + data
self.goahead(0)
- # Interface -- handle the remaining data
def close(self):
self.goahead(1)
--- 79,101 ----
self.literal = 0
def setnomoretags(self):
+ """Enter literal mode (CDATA) till EOF. Intended for derived
+ classes only."""
self.nomoretags = self.literal = 1
def setliteral(self, *args):
+ """Enter literal mode (CDATA). Intended for derived classes only."""
self.literal = 1
def feed(self, data):
+ """Feed some data to the parser. Call this as often as you
+ want, with as little or as much text as you want (may include
+ '\n'). (This just saves the text, all the processing is done
+ by goahead().)"""
self.rawdata = self.rawdata + data
self.goahead(0)
def close(self):
+ """Handle the remaining data."""
self.goahead(1)
***************
*** 408,413 ****
print '*** Stack:', self.stack
- # Example -- handle character reference, no need to override
def handle_charref(self, name):
try:
n = int(name)
--- 409,414 ----
print '*** Stack:', self.stack
def handle_charref(self, name):
+ """Handle character reference, no need to override."""
try:
n = int(name)
***************
*** 424,429 ****
{'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''}
- # Example -- handle entity reference, no need to override
def handle_entityref(self, name):
table = self.entitydefs
if table.has_key(name):
--- 425,434 ----
{'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''}
def handle_entityref(self, name):
+ """Handle entity references.
+
+ There should be no need to override this method; it can be
+ tailored by setting up the self.entitydefs mapping appropriately.
+ """
table = self.entitydefs
if table.has_key(name):