summaryrefslogtreecommitdiffstats
path: root/Lib/markupbase.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-10-26 18:02:28 (GMT)
committerFred Drake <fdrake@acm.org>2001-10-26 18:02:28 (GMT)
commit5445f078df1dc986259f75f6345afea19b27cb59 (patch)
tree4140acb5b1080811dc7899eb388d70d9bd3431ec /Lib/markupbase.py
parentc916f5a390b0ca559de54a15d4014e18792674ea (diff)
downloadcpython-5445f078df1dc986259f75f6345afea19b27cb59.zip
cpython-5445f078df1dc986259f75f6345afea19b27cb59.tar.gz
cpython-5445f078df1dc986259f75f6345afea19b27cb59.tar.bz2
Re-arrange things and remove some unused variables/imports to keep pychecker
happy. (This does not cover everything it complained about, though.)
Diffstat (limited to 'Lib/markupbase.py')
-rw-r--r--Lib/markupbase.py17
1 files changed, 14 insertions, 3 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 ("<!DOCTYPE html...>").
rawdata = self.rawdata
- import sys
j = i + 2
assert rawdata[i:j] == "<!", "unexpected call to parse_declaration"
if rawdata[j:j+1] in ("-", ""):
@@ -162,12 +170,11 @@ class ParserBase:
# Internal -- scan past <!ELEMENT declarations
def _parse_doctype_element(self, i, declstartpos):
- rawdata = self.rawdata
- n = len(rawdata)
name, j = self._scan_name(i, declstartpos)
if j == -1:
return -1
# style content model; just skip until '>'
+ 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