From 5445f078df1dc986259f75f6345afea19b27cb59 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 26 Oct 2001 18:02:28 +0000 Subject: Re-arrange things and remove some unused variables/imports to keep pychecker happy. (This does not cover everything it complained about, though.) --- Lib/markupbase.py | 17 ++++++++++++++--- Lib/sgmllib.py | 1 - 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Lib/markupbase.py b/Lib/markupbase.py index 32237af..57d3ae4 100644 --- a/Lib/markupbase.py +++ b/Lib/markupbase.py @@ -13,6 +13,15 @@ class ParserBase: """Parser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.""" + def __init__(self): + if self.__class__ is ParserBase: + raise RuntimeError( + "markupbase.ParserBase must be subclassed") + + def error(self, message): + raise NotImplementedError( + "subclasses of ParserBase must override error()") + def reset(self): self.lineno = 1 self.offset = 0 @@ -46,7 +55,6 @@ class ParserBase: # deployed," this should only be the document type # declaration (""). rawdata = self.rawdata - import sys j = i + 2 assert rawdata[i:j] == "' + rawdata = self.rawdata if '>' in rawdata[j:]: return string.find(rawdata, ">", j) + 1 return -1 @@ -304,3 +311,7 @@ class ParserBase: else: self.updatepos(declstartpos, i) self.error("expected name token") + + # To be overridden -- handlers for unknown objects + def unknown_decl(self, data): + pass diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 2de7492..1db5423 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -423,7 +423,6 @@ class SGMLParser(markupbase.ParserBase): def unknown_endtag(self, tag): pass def unknown_charref(self, ref): pass def unknown_entityref(self, ref): pass - def unknown_decl(self, data): pass class TestSGMLParser(SGMLParser): -- cgit v0.12