display parse errors

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@865 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2003-04-30 01:21:24 +00:00
parent 7f4591a112
commit a795fd19db
2 changed files with 28 additions and 0 deletions

View file

@ -5,6 +5,9 @@
* only remove anchors on IIS servers (other servers are doing quite
well with anchors... can you spell A-p-a-c-h-e ?)
Changed files: linkcheck/{HttpUrlData, UrlData}.py
* correctly propagate and display parsing errors
Changed files: linkcheck/parser/html{lex.l, parse.y},
linkcheck/linkparse.py
1.8.13
* fix typo in manpage

View file

@ -64,6 +64,8 @@ class LinkParser (HtmlParser):
self.content = content
self.tags = tags
self.urls = []
# warnings and errors during parsing
self.parse_info = []
self.feed(self.content)
debug(HURT_ME_PLENTY, "flushing")
self.flush()
@ -108,3 +110,26 @@ class LinkParser (HtmlParser):
self.urls.append((url, self.last_lineno(), self.last_column(),
name, base))
def _errorfun (self, msg, name):
"""append msg to error list"""
pos = "%d:%d" % (self.lineno(), self.column())
self.parse_info.append("%s: %s: %s" % (name, pos, msg))
print >> sys.stderr, name, pos, msg
def error (self, msg):
"""signal a filter/parser error"""
self._errorfun(msg, "error:")
def warning (self, msg):
"""signal a filter/parser warning"""
self._errorfun(msg, "warning:")
def fatalError (self, msg):
"""signal a fatal filter/parser error"""
self._errorfun(msg, "fatal error:")