1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Python 3 sgmllib fix

sgmllib is deprecated in Python 3, it was replaced by html.parser
This commit is contained in:
Roderik Ploszek 2018-02-18 17:28:25 +01:00
parent c63bceab5e
commit 72ad11c9ee

View file

@ -4,18 +4,18 @@ See the HTML 2.0 specification:
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
""" """
import sgmllib import html.parser as htmllib
from formatter import AS_IS from formatter import AS_IS
__all__ = ["HTMLParser", "HTMLParseError"] __all__ = ["HTMLParser", "HTMLParseError"]
class HTMLParseError(sgmllib.SGMLParseError): class HTMLParseError(RuntimeError):
"""Error raised when an HTML document can't be parsed.""" """Error raised when an HTML document can't be parsed."""
class HTMLParser(sgmllib.SGMLParser): class HTMLParser(htmllib.HTMLParser):
"""This is the basic HTML parser class. """This is the basic HTML parser class.
It supports all entity names required by the XHTML 1.0 Recommendation. It supports all entity names required by the XHTML 1.0 Recommendation.
@ -33,14 +33,14 @@ class HTMLParser(sgmllib.SGMLParser):
the parser. the parser.
""" """
sgmllib.SGMLParser.__init__(self, verbose) htmllib.HTMLParser.__init__(self)
self.formatter = formatter self.formatter = formatter
def error(self, message): def error(self, message):
raise HTMLParseError(message) raise HTMLParseError(message)
def reset(self): def reset(self):
sgmllib.SGMLParser.reset(self) htmllib.HTMLParser.reset(self)
self.savedata = None self.savedata = None
self.isindex = 0 self.isindex = 0
self.title = None self.title = None