mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-27 09:34:42 +00:00
replace backticks with repr
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1121 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
fbfa5ee64e
commit
95611de5c3
12 changed files with 53 additions and 42 deletions
|
|
@ -57,13 +57,13 @@ def esc_ansicolor (color):
|
|||
if ";" in color:
|
||||
ctype, color = color.split(";", 1)
|
||||
if not AnsiType.has_key(ctype):
|
||||
print >>sys.stderr, "invalid ANSI color type", `ctype`
|
||||
print >>sys.stderr, "invalid ANSI color type", repr(ctype)
|
||||
print >>sys.stderr, "valid values are", AnsiType.keys()
|
||||
ctype = ''
|
||||
else:
|
||||
ctype = AnsiType[ctype]+";"
|
||||
if not AnsiColor.has_key(color):
|
||||
print >>sys.stderr, "invalid ANSI color name", `color`
|
||||
print >>sys.stderr, "invalid ANSI color name", repr(color)
|
||||
print >>sys.stderr, "valid values are", AnsiColor.keys()
|
||||
cnum = '0'
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -31,10 +31,13 @@ for _name in _names:
|
|||
if _name[0] != '_': classmap[eval(_name)] = _name
|
||||
|
||||
def classstr(klass):
|
||||
return classmap.get(klass, `klass`)
|
||||
return classmap.get(klass, repr(klass))
|
||||
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 2003/12/20 11:28:15 calvin
|
||||
# replace backticks with repr
|
||||
#
|
||||
# Revision 1.4 2003/07/04 14:23:22 calvin
|
||||
# add coding line
|
||||
#
|
||||
|
|
|
|||
|
|
@ -543,17 +543,17 @@ class DnsResult:
|
|||
print
|
||||
print ';; ANSWERS:'
|
||||
for a in self.answers:
|
||||
print '%-20s %-6s %-6s %s'%(a['name'],`a['ttl']`,a['typename'],
|
||||
print '%-20s %-6r %-6s %s'%(a['name'],a['ttl'],a['typename'],
|
||||
a['data'])
|
||||
print
|
||||
print ';; AUTHORITY RECORDS:'
|
||||
for a in self.authority:
|
||||
print '%-20s %-6s %-6s %s'%(a['name'],`a['ttl']`,a['typename'],
|
||||
print '%-20s %-6r %-6s %s'%(a['name'],a['ttl'],a['typename'],
|
||||
a['data'])
|
||||
print
|
||||
print ';; ADDITIONAL RECORDS:'
|
||||
for a in self.additional:
|
||||
print '%-20s %-6s %-6s %s'%(a['name'],`a['ttl']`,a['typename'],
|
||||
print '%-20s %-6r %-6s %s'%(a['name'],a['ttl'],a['typename'],
|
||||
a['data'])
|
||||
print
|
||||
if self.args.has_key('elapsed'):
|
||||
|
|
@ -631,6 +631,9 @@ if __name__ == "__main__":
|
|||
testpacker()
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.6 2003/12/20 11:28:15 calvin
|
||||
# replace backticks with repr
|
||||
#
|
||||
# Revision 1.5 2003/07/04 14:23:22 calvin
|
||||
# add coding line
|
||||
#
|
||||
|
|
|
|||
|
|
@ -26,10 +26,13 @@ for _name in _names:
|
|||
if _name[0] != '_': opcodemap[eval(_name)] = _name
|
||||
|
||||
def opcodestr(opcode):
|
||||
return opcodemap.get(opcode, `opcode`)
|
||||
return opcodemap.get(opcode, repr(opcode))
|
||||
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 2003/12/20 11:28:15 calvin
|
||||
# replace backticks with repr
|
||||
#
|
||||
# Revision 1.4 2003/07/04 14:23:22 calvin
|
||||
# add coding line
|
||||
#
|
||||
|
|
|
|||
|
|
@ -37,10 +37,13 @@ for _name in _names:
|
|||
if _name[0] != '_': statusmap[eval(_name)] = _name
|
||||
|
||||
def statusstr(status):
|
||||
return statusmap.get(status, `status`)
|
||||
return statusmap.get(status, repr(status))
|
||||
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 2003/12/20 11:28:15 calvin
|
||||
# replace backticks with repr
|
||||
#
|
||||
# Revision 1.4 2003/07/04 14:23:22 calvin
|
||||
# add coding line
|
||||
#
|
||||
|
|
|
|||
|
|
@ -49,10 +49,13 @@ typemap = {}
|
|||
for _name in _names:
|
||||
if _name[0] != '_': typemap[eval(_name)] = _name
|
||||
|
||||
def typestr(type):
|
||||
return typemap.get(type, `type`)
|
||||
def typestr (_type):
|
||||
return typemap.get(_type, repr(_type))
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 2003/12/20 11:28:15 calvin
|
||||
# replace backticks with repr
|
||||
#
|
||||
# Revision 1.4 2003/07/04 14:23:22 calvin
|
||||
# add coding line
|
||||
#
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
# set the proxy, so a 407 status after this is an error
|
||||
self.setProxy(self.config["proxy"].get(self.scheme))
|
||||
if self.proxy:
|
||||
self.setInfo(i18n._("Using Proxy %s")%`self.proxy`)
|
||||
self.setInfo(i18n._("Using Proxy %r")%self.proxy)
|
||||
self.headers = None
|
||||
self.auth = None
|
||||
self.cookies = []
|
||||
|
|
@ -126,7 +126,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
if response.status == 305 and self.headers:
|
||||
oldproxy = (self.proxy, self.proxyauth)
|
||||
self.setProxy(self.headers.getheader("Location"))
|
||||
self.setInfo(i18n._("Enforced Proxy %s")%`self.proxy`)
|
||||
self.setInfo(i18n._("Enforced Proxy %r")%self.proxy)
|
||||
response = self._getHttpResponse()
|
||||
self.headers = response.msg
|
||||
self.proxy, self.proxyauth = oldproxy
|
||||
|
|
@ -169,7 +169,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
# scheme, eg https or news
|
||||
if self.urlparts[0]!="http":
|
||||
self.setWarning(i18n._("HTTP redirection to non-http url encountered; "
|
||||
"the original url was %s.") % `self.url`)
|
||||
"the original url was %r.")%self.url)
|
||||
# make new UrlData object
|
||||
newobj = GetUrlDataFrom(redirected, self.recursionLevel, self.config,
|
||||
parentName=self.parentName, baseRef=self.baseRef,
|
||||
|
|
@ -215,11 +215,11 @@ class HttpUrlData (ProxyUrlData):
|
|||
elif response.status>=400 and self.headers:
|
||||
server = self.headers.get('Server', '')
|
||||
if _isBrokenHeadServer(server):
|
||||
self.setWarning(i18n._("Server %s has no HEAD support, falling back to GET") % `server`)
|
||||
self.setWarning(i18n._("Server %r has no HEAD support, falling back to GET")%server)
|
||||
response = self._getHttpResponse("GET")
|
||||
self.headers = response.msg
|
||||
elif _isBrokenAnchorServer(server):
|
||||
self.setWarning(i18n._("Server %s has no anchor support, removing anchor from request") % `server`)
|
||||
self.setWarning(i18n._("Server %r has no anchor support, removing anchor from request")%server)
|
||||
self.urlparts[4] = ''
|
||||
response = self._getHttpResponse()
|
||||
self.headers = response.msg
|
||||
|
|
@ -248,7 +248,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
def checkResponse (self, response):
|
||||
"""check final result"""
|
||||
if response.status >= 400:
|
||||
self.setError(`response.status`+" "+response.reason)
|
||||
self.setError("%r %s"%(response.status, response.reason))
|
||||
else:
|
||||
if response.status == 204:
|
||||
# no content
|
||||
|
|
@ -261,7 +261,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
for h in out:
|
||||
self.setInfo(h)
|
||||
if response.status >= 200:
|
||||
self.setValid(`response.status`+" "+response.reason)
|
||||
self.setValid("%r %s"%(response.status,response.reason))
|
||||
else:
|
||||
self.setValid("OK")
|
||||
modified = self.headers.get('Last-Modified', '')
|
||||
|
|
@ -365,8 +365,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
encoding = self.headers.get("Content-Encoding")
|
||||
if encoding and encoding not in _supported_encodings and \
|
||||
encoding!='identity':
|
||||
self.setWarning(i18n._('Unsupported content encoding %s.')%\
|
||||
`encoding`)
|
||||
self.setWarning(i18n._('Unsupported content encoding %r.')%encoding)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
@ -379,8 +378,7 @@ class HttpUrlData (ProxyUrlData):
|
|||
encoding = self.headers.get("Content-Encoding")
|
||||
if encoding and encoding not in _supported_encodings and \
|
||||
encoding!='identity':
|
||||
self.setWarning(i18n._('Unsupported content encoding %s.')%\
|
||||
`encoding`)
|
||||
self.setWarning(i18n._('Unsupported content encoding %r.')%encoding)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ def print_app_info ():
|
|||
for key in ("LC_ALL", "LC_MESSAGES", "http_proxy", "ftp_proxy"):
|
||||
value = os.getenv(key)
|
||||
if value is not None:
|
||||
print >>sys.stderr, key, "=", `value`
|
||||
print >>sys.stderr, key, "=", repr(value)
|
||||
|
||||
|
||||
def get_absolute_url (urlName, baseRef, parentName):
|
||||
|
|
@ -504,8 +504,7 @@ class UrlData (object):
|
|||
return
|
||||
match = warningregex.search(self.getContent())
|
||||
if match:
|
||||
self.setWarning(i18n._("Found %s in link contents") % \
|
||||
`match.group()`)
|
||||
self.setWarning(i18n._("Found %r in link contents")%match.group())
|
||||
|
||||
|
||||
def checkSize (self):
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class LinkCheckerError (Exception):
|
|||
import re, i18n
|
||||
def getLinkPat (arg, strict=False):
|
||||
"""get a link pattern matcher for intern/extern links"""
|
||||
debug(BRING_IT_ON, "Link pattern", `arg`)
|
||||
debug(BRING_IT_ON, "Link pattern %r", arg)
|
||||
if arg[0:1] == '!':
|
||||
pattern = arg[1:]
|
||||
negate = True
|
||||
|
|
|
|||
|
|
@ -88,4 +88,4 @@ class Logger (object):
|
|||
|
||||
|
||||
def __repr__ (self):
|
||||
return `self.__class__.__name__`
|
||||
return repr(self.__class__.__name__)
|
||||
|
|
|
|||
|
|
@ -176,8 +176,7 @@ class RobotFileParser (object):
|
|||
|
||||
def can_fetch (self, useragent, url):
|
||||
"""using the parsed robots.txt decide if useragent can fetch url"""
|
||||
debug(BRING_IT_ON, "Checking robot.txt allowance for:\n user agent: %s\n url: %s" %
|
||||
(`useragent`, `url`))
|
||||
debug(BRING_IT_ON, "Checking robot.txt allowance for:\n user agent: %r\n url: %r"%(useragent, url))
|
||||
if self.disallow_all:
|
||||
return False
|
||||
if self.allow_all:
|
||||
|
|
@ -229,7 +228,7 @@ class Entry:
|
|||
|
||||
|
||||
def __str__ (self):
|
||||
lines = ["User-agent: %s"%`agent` for agent in self.useragents]
|
||||
lines = ["User-agent: %r"%agent for agent in self.useragents]
|
||||
lines.extend([str(line) for line in self.rulelines])
|
||||
return "\n".join(lines)
|
||||
|
||||
|
|
@ -294,7 +293,7 @@ def decode (page):
|
|||
else:
|
||||
fp = gzip.GzipFile('', 'rb', 9, StringIO(content))
|
||||
except zlib.error, msg:
|
||||
warn(i18n._("%s at %s, assuming non-compressed content") % (`str(msg)`, page.geturl()))
|
||||
warn(i18n._("%r at %s, assuming non-compressed content") % (str(msg), page.geturl()))
|
||||
fp = StringIO(content)
|
||||
# remove content-encoding header
|
||||
headers = {}
|
||||
|
|
|
|||
24
linkchecker
24
linkchecker
|
|
@ -328,13 +328,13 @@ for opt,arg in options:
|
|||
try:
|
||||
wait = int(arg)
|
||||
except ValueError:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'-P, --pause'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'-P, --pause'"))
|
||||
if wait >= 0:
|
||||
config["wait"] = wait
|
||||
else:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'-P, --pause'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'-P, --pause'"))
|
||||
|
||||
elif opt=="--profile":
|
||||
do_profile = True
|
||||
|
|
@ -346,8 +346,8 @@ for opt,arg in options:
|
|||
try:
|
||||
depth = int(arg)
|
||||
except ValueError:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'-r, --recursion-level'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'-r, --recursion-level'"))
|
||||
if depth >= 0:
|
||||
config["recursionlevel"] = depth
|
||||
else:
|
||||
|
|
@ -362,8 +362,8 @@ for opt,arg in options:
|
|||
try:
|
||||
num = int(arg)
|
||||
except ValueError:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'-t, --threads'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'-t, --threads'"))
|
||||
if num > 1 and not get_debuglevel() > 0:
|
||||
config.enableThreading(num)
|
||||
else:
|
||||
|
|
@ -373,11 +373,11 @@ for opt,arg in options:
|
|||
try:
|
||||
timeout = int(arg)
|
||||
except ValueError:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'--timeout'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'--timeout'"))
|
||||
if timeout <= 0:
|
||||
printUsage(i18n._("Illegal argument %s for option %s") % \
|
||||
(`arg`, "'--timeout'"))
|
||||
printUsage(i18n._("Illegal argument %r for option %s") % \
|
||||
(arg, "'--timeout'"))
|
||||
socket.setdefaulttimeout(timeout)
|
||||
|
||||
elif opt=="-u" or opt=="--user":
|
||||
|
|
|
|||
Loading…
Reference in a new issue