python 2.0 fix

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@224 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2001-01-11 20:32:11 +00:00
parent af22738035
commit a2ceebf3eb
5 changed files with 32 additions and 19 deletions

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
linkchecker (1.2.14) unstable; urgency=low
* fixed Python 2.0 bug: TypeError: object has read-only attributes
-- Bastian Kleineidam <calvin@users.sourceforge.net> Thu, 11 Jan 2001 21:29:00 +0100
linkchecker (1.2.13) unstable; urgency=low linkchecker (1.2.13) unstable; urgency=low
* linkcheck/HttpUrlData.py: * linkcheck/HttpUrlData.py:

View file

@ -1,6 +1,6 @@
""" linkcheck/Config.py """ linkcheck/Config.py
Copyright (C) 2000 Bastian Kleineidam Copyright (C) 2000,2001 Bastian Kleineidam
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,8 +35,8 @@ App = AppName+" "+Version
UserAgent = AppName+"/"+Version UserAgent = AppName+"/"+Version
Author = LinkCheckerConf.author Author = LinkCheckerConf.author
HtmlAuthor = string.replace(Author, ' ', '&nbsp;') HtmlAuthor = string.replace(Author, ' ', '&nbsp;')
Copyright = "Copyright © 2000 by "+Author Copyright = "Copyright © 2000,2001 by "+Author
HtmlCopyright = "Copyright &copy; 2000 by "+HtmlAuthor HtmlCopyright = "Copyright &copy; 2000,2001 by "+HtmlAuthor
AppInfo = App+" "+Copyright AppInfo = App+" "+Copyright
HtmlAppInfo = App+", "+HtmlCopyright HtmlAppInfo = App+", "+HtmlCopyright
Url = LinkCheckerConf.url Url = LinkCheckerConf.url

View file

@ -66,10 +66,22 @@ LinkTags = (
LinkPatterns = [] LinkPatterns = []
for tag,attr in LinkTags: for tag,attr in LinkTags:
pattern = re.compile(_linkMatcher % (tag, attr), re.VERBOSE) LinkPatterns.append({'pattern': re.compile(_linkMatcher % (tag, attr),
pattern.tag = tag re.VERBOSE),
pattern.attr = attr 'tag': tag,
LinkPatterns.append(pattern) 'attr': attr})
AnchorPattern = {
'pattern': re.compile(_linkMatcher % ("a", "name"), re.VERBOSE),
'tag': 'a',
'attr': 'name',
}
BasePattern = {
'pattern': re.compile(_linkMatcher % ("base", "href"), re.VERBOSE),
'tag': 'base',
'attr': 'href',
}
class UrlData: class UrlData:
"Representing a URL with additional information like validity etc" "Representing a URL with additional information like validity etc"
@ -260,10 +272,7 @@ class UrlData:
if not (anchor!="" and self.isHtml() and self.valid): if not (anchor!="" and self.isHtml() and self.valid):
return return
self.getContent() self.getContent()
pattern = re.compile(_linkMatcher % ("a", "name"), re.VERBOSE) for cur_anchor,line in self.searchInForTag(AnchorPattern):
pattern.tag = "a"
pattern.attr = "name"
for cur_anchor,line in self.searchInForTag(pattern):
if cur_anchor == anchor: if cur_anchor == anchor:
return return
self.setWarning("anchor #"+anchor+" not found") self.setWarning("anchor #"+anchor+" not found")
@ -331,10 +340,7 @@ class UrlData:
debug(Config.DebugDelim+"Parsing recursively into\n"+\ debug(Config.DebugDelim+"Parsing recursively into\n"+\
str(self)+"\n"+Config.DebugDelim) str(self)+"\n"+Config.DebugDelim)
# search for a possible base reference # search for a possible base reference
pattern = re.compile(_linkMatcher % ("base", "href"), re.VERBOSE) bases = self.searchInForTag(BasePattern)
pattern.tag = "base"
pattern.attr = "href"
bases = self.searchInForTag(pattern)
baseRef = None baseRef = None
if len(bases)>=1: if len(bases)>=1:
@ -352,11 +358,11 @@ class UrlData:
def searchInForTag(self, pattern): def searchInForTag(self, pattern):
debug("Searching for tag %s, attribute %s" \ debug("Searching for tag %s, attribute %s" \
% (pattern.tag, pattern.attr)) % (pattern['tag'], pattern['attr']))
urls = [] urls = []
index = 0 index = 0
while 1: while 1:
match = pattern.search(self.getContent(), index) match = pattern['pattern'].search(self.getContent(), index)
if not match: break if not match: break
index = match.end() index = match.end()
if self._isInComment(match.start()): continue if self._isInComment(match.start()): continue
@ -364,7 +370,7 @@ class UrlData:
url = string.strip(StringUtil.stripQuotes(match.group('value'))) url = string.strip(StringUtil.stripQuotes(match.group('value')))
lineno=StringUtil.getLineNumber(self.getContent(), match.start()) lineno=StringUtil.getLineNumber(self.getContent(), match.start())
# extra feature: get optional name for this bookmark # extra feature: get optional name for this bookmark
name = self.searchInForName(pattern.tag, pattern.attr, name = self.searchInForName(pattern['tag'], pattern['attr'],
match.start(), match.end()) match.start(), match.end())
urls.append((url, lineno, name)) urls.append((url, lineno, name))
return urls return urls

View file

@ -55,6 +55,7 @@
#filename=linkchecker-out.ansi #filename=linkchecker-out.ansi
#colorparent= #colorparent=
#colorurl= #colorurl=
#colorname=
#colorreal= #colorreal=
#colorbase= #colorbase=
#colorvalid= #colorvalid=

View file

@ -215,7 +215,7 @@ myname = "Bastian Kleineidam"
myemail = "calvin@users.sourceforge.net" myemail = "calvin@users.sourceforge.net"
setup (name = "LinkChecker", setup (name = "LinkChecker",
version = "1.2.13", version = "1.2.14",
description = "check HTML documents for broken links", description = "check HTML documents for broken links",
author = myname, author = myname,
author_email = myemail, author_email = myemail,