mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-20 22:31:00 +00:00
use string methods
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@339 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
af4467ec8d
commit
fbdf5f570b
10 changed files with 45 additions and 39 deletions
6
debian/changelog
vendored
6
debian/changelog
vendored
|
|
@ -1,3 +1,9 @@
|
|||
linkchecker (1.3.12) unstable; urgency=low
|
||||
|
||||
* use string methods where possible
|
||||
|
||||
-- Bastian Kleineidam <calvin@debian.org> Sat, 1 Dec 2001 12:13:37 +0100
|
||||
|
||||
linkchecker (1.3.11) unstable; urgency=low
|
||||
|
||||
* setup.py: use os.getcwd(), not "." which breaks on MacOS 9.x
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ class CSV(UserList.UserList):
|
|||
else:
|
||||
raise Exception("Invalid comment type '" + comment + "'")
|
||||
|
||||
lines = map(string.strip, string.split(data, "\n"))
|
||||
lines = map(string.strip, data.splitlines())
|
||||
|
||||
# Remove all comments that are of type string
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ AppName = "LinkChecker"
|
|||
App = AppName+" "+Version
|
||||
UserAgent = AppName+"/"+Version
|
||||
Author = _linkchecker_configdata.author
|
||||
HtmlAuthor = string.replace(Author, ' ', ' ')
|
||||
HtmlAuthor = Author.replace(' ', ' ')
|
||||
Copyright = "Copyright © 2000,2001 by "+Author
|
||||
HtmlCopyright = "Copyright © 2000,2001 by "+HtmlAuthor
|
||||
AppInfo = App+" "+Copyright
|
||||
|
|
@ -403,7 +403,7 @@ class Configuration(UserDict.UserDict):
|
|||
except ConfigParser.Error, msg: debug(str(msg)+"\n")
|
||||
try:
|
||||
self[key]['fields'] = map(string.strip,
|
||||
string.split(cfgparser.get(key, 'fields'), ','))
|
||||
cfgparser.get(key, 'fields').split(','))
|
||||
except ConfigParser.Error, msg:
|
||||
debug(BRING_IT_ON, msg)
|
||||
try:
|
||||
|
|
@ -423,9 +423,9 @@ class Configuration(UserDict.UserDict):
|
|||
try: self["warnings"] = cfgparser.getboolean(section, "warnings")
|
||||
except ConfigParser.Error: pass
|
||||
try:
|
||||
filelist = string.split(cfgparser.get(section, "fileoutput"), ",")
|
||||
filelist = cfgparser.get(section, "fileoutput").split(",")
|
||||
for arg in filelist:
|
||||
arg = string.strip(arg)
|
||||
arg = arg.strip()
|
||||
# no file output for the blacklist Logger
|
||||
if Loggers.has_key(arg) and arg != "blacklist":
|
||||
self['fileoutput'].append(
|
||||
|
|
@ -470,7 +470,7 @@ class Configuration(UserDict.UserDict):
|
|||
try:
|
||||
i=1
|
||||
while 1:
|
||||
auth = string.split(cfgparser.get(section, "entry%d" % i))
|
||||
auth = cfgparser.get(section, "entry%d" % i).split()
|
||||
if len(auth)!=3: break
|
||||
auth[0] = re.compile(auth[0])
|
||||
self["authentication"].insert(0, {'pattern': auth[0],
|
||||
|
|
@ -483,7 +483,7 @@ class Configuration(UserDict.UserDict):
|
|||
try:
|
||||
i=1
|
||||
while 1:
|
||||
tuple = string.split(cfgparser.get(section, "extern%d" % i))
|
||||
tuple = cfgparser.get(section, "extern%d" % i).split()
|
||||
if len(tuple)!=2: break
|
||||
self["externlinks"].append((re.compile(tuple[0]),
|
||||
int(tuple[1])))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import socket,string
|
||||
import socket
|
||||
from UrlData import UrlData
|
||||
from linkcheck import _
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import sys,time,string
|
||||
import sys, time
|
||||
from types import ListType
|
||||
import Config, StringUtil
|
||||
import linkcheck
|
||||
|
|
@ -52,7 +52,7 @@ def quote(s):
|
|||
for i in range(len(res)):
|
||||
c = res[i]
|
||||
res[i] = EntityTable.get(c, c)
|
||||
return string.joinfields(res, '')
|
||||
return ''.join(res)
|
||||
|
||||
# return formatted time
|
||||
def _strtime(t):
|
||||
|
|
@ -299,7 +299,7 @@ class HtmlLogger(StandardLogger):
|
|||
if self.logfield("warning"):
|
||||
self.fd.write("<tr>"+self.tablewarning+_("Warning")+
|
||||
"</td>"+self.tablewarning+
|
||||
string.replace(urlData.warningString, "\n", "<br>")+
|
||||
urlData.warningString.replace("\n", "<br>")+
|
||||
"</td></tr>\n")
|
||||
if self.logfield("result"):
|
||||
if urlData.valid:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import re,string,time,sys,nntplib,urlparse,linkcheck
|
||||
import re, time, sys, nntplib, urlparse, linkcheck
|
||||
from linkcheck import _
|
||||
from UrlData import ExcList,UrlData
|
||||
debug = linkcheck.Config.debug
|
||||
|
|
@ -37,7 +37,7 @@ class NntpUrlData(UrlData):
|
|||
# use nntp instead of news to comply with the unofficial internet
|
||||
# draft of Alfred Gilman which unifies (s)news and nntp URLs
|
||||
# note: we use this only internally (for parsing and caching)
|
||||
if string.lower(self.urlName[:4])=='news':
|
||||
if self.urlName[:4].lower()=='news':
|
||||
self.url = 'nntp'+self.urlName[4:]
|
||||
else:
|
||||
self.url = self.urlName
|
||||
|
|
@ -60,7 +60,7 @@ class NntpUrlData(UrlData):
|
|||
self.setInfo(_('Articel number %s found' % number))
|
||||
else:
|
||||
# split off trailing articel span
|
||||
group = string.split(group,'/',1)[0]
|
||||
group = group.split('/',1)[0]
|
||||
if group:
|
||||
# request group info
|
||||
resp,count,first,last,name = nntp.group(group)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import string,re,sys,htmlentitydefs
|
||||
import re, sys, htmlentitydefs
|
||||
|
||||
markup_re = re.compile("<.*?>", re.DOTALL)
|
||||
|
||||
|
|
@ -35,19 +35,19 @@ TeXTable = []
|
|||
|
||||
def stripHtmlComments(data):
|
||||
"Remove <!-- ... --> HTML comments from data"
|
||||
i = string.find(data, "<!--")
|
||||
i = data.find("<!--")
|
||||
while i!=-1:
|
||||
j = string.find(data, "-->", i)
|
||||
j = data.find("-->", i)
|
||||
if j == -1:
|
||||
break
|
||||
data = data[:i] + data[j+3:]
|
||||
i = string.find(data, "<!--")
|
||||
i = data.find("<!--")
|
||||
return data
|
||||
|
||||
|
||||
def stripFenceComments(data):
|
||||
"Remove # ... comments from data"
|
||||
lines = string.split(data, "\n")
|
||||
lines = data.split("\n")
|
||||
ret = None
|
||||
for line in lines:
|
||||
if not re.compile("\s*#.*").match(line):
|
||||
|
|
@ -105,7 +105,7 @@ def indentWith(s, indent):
|
|||
def blocktext(s, width):
|
||||
"Adjust lines of s to be not wider than width"
|
||||
# split into lines
|
||||
s = string.split(s, "\n")
|
||||
s = s.split("\n")
|
||||
s.reverse()
|
||||
line = None
|
||||
ret = ""
|
||||
|
|
@ -116,8 +116,8 @@ def blocktext(s, width):
|
|||
line = s.pop()
|
||||
while len(line) > width:
|
||||
i = getLastWordBoundary(line, width)
|
||||
ret += string.strip(line[0:i]) + "\n"
|
||||
line = string.strip(line[i:])
|
||||
ret += line[0:i].strip() + "\n"
|
||||
line = line[i:].strip()
|
||||
return ret + line
|
||||
|
||||
|
||||
|
|
@ -130,11 +130,11 @@ def getLastWordBoundary(s, width):
|
|||
return width-1
|
||||
|
||||
|
||||
def applyTable(table, str):
|
||||
def applyTable(table, s):
|
||||
"apply a table of replacement pairs to str"
|
||||
for mapping in table:
|
||||
str = string.replace(str, mapping[0], mapping[1])
|
||||
return str
|
||||
s = s.replace(mapping[0], mapping[1])
|
||||
return s
|
||||
|
||||
|
||||
def texify(str):
|
||||
|
|
@ -171,7 +171,7 @@ def getLineNumber(str, index):
|
|||
|
||||
def paginate(text, lines=22):
|
||||
"""print text in pages of lines size"""
|
||||
textlines = string.split(text, "\n")
|
||||
textlines = text.split("\n")
|
||||
curline = 1
|
||||
for line in textlines:
|
||||
print line
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import telnetlib,re,string,linkcheck
|
||||
import telnetlib, re, linkcheck
|
||||
from HostCheckingUrlData import HostCheckingUrlData
|
||||
from linkcheck import _
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class TelnetUrlData(HostCheckingUrlData):
|
|||
HostCheckingUrlData.buildUrl(self)
|
||||
if not telnet_re.match(self.urlName):
|
||||
raise linkcheck.error, _("Illegal telnet link syntax")
|
||||
self.host = string.lower(self.urlName[7:])
|
||||
self.host = self.urlName[7:].lower()
|
||||
|
||||
def get_scheme(self):
|
||||
return "telnet"
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class record:
|
|||
cLen & 255,
|
||||
padLen,
|
||||
0]
|
||||
hdr = string.joinfields(map(chr, hdr), '')
|
||||
hdr = ''.join(map(chr, hdr))
|
||||
|
||||
sock.send(hdr + content + padLen*'\000')
|
||||
|
||||
|
|
@ -267,8 +267,8 @@ class FastCGIWriter:
|
|||
data = data[8192:]
|
||||
return chunk, data
|
||||
|
||||
def writelines(self, list):
|
||||
self.write(string.joinfields(list, ''))
|
||||
def writelines(self, lines):
|
||||
self.write(''.join(lines))
|
||||
|
||||
def flush(self):
|
||||
if self.closed:
|
||||
|
|
@ -304,7 +304,7 @@ class FCGI:
|
|||
|
||||
if os.environ.has_key('FCGI_WEB_SERVER_ADDRS'):
|
||||
good_addrs=map(string.strip,
|
||||
string.split(os.environ['FCGI_WEB_SERVER_ADDRS'], ','))
|
||||
os.environ['FCGI_WEB_SERVER_ADDRS'].split(','))
|
||||
else:
|
||||
good_addrs=None
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ class FCGI:
|
|||
def getFieldStorage(self):
|
||||
method = 'GET'
|
||||
if self.env.has_key('REQUEST_METHOD'):
|
||||
method = string.upper(self.env['REQUEST_METHOD'])
|
||||
method = self.env['REQUEST_METHOD'].upper()
|
||||
if method == 'GET':
|
||||
return cgi.FieldStorage(environ=self.env, keep_blank_values=1)
|
||||
else:
|
||||
|
|
@ -435,7 +435,7 @@ def _test():
|
|||
|
||||
try:
|
||||
fs = req.getFieldStorage()
|
||||
size = string.atoi(fs['size'].value)
|
||||
size = int(fs['size'].value)
|
||||
doc = ['*' * size]
|
||||
except:
|
||||
doc = ['<HTML><HEAD><TITLE>FCGI TestApp</TITLE></HEAD>\n<BODY>\n']
|
||||
|
|
@ -443,7 +443,7 @@ def _test():
|
|||
doc.append('<b>request count</b> = %d<br>' % counter)
|
||||
doc.append('<b>pid</b> = %s<br>' % os.getpid())
|
||||
if req.env.has_key('CONTENT_LENGTH'):
|
||||
cl = string.atoi(req.env['CONTENT_LENGTH'])
|
||||
cl = int(req.env['CONTENT_LENGTH'])
|
||||
doc.append('<br><b>POST data (%s):</b><br><pre>' % cl)
|
||||
keys = fs.keys()
|
||||
keys.sort()
|
||||
|
|
@ -465,7 +465,7 @@ def _test():
|
|||
doc.append('</BODY></HTML>\n')
|
||||
|
||||
|
||||
doc = string.join(doc, '')
|
||||
doc = ''.join(doc)
|
||||
req.out.write('Content-length: %s\r\n'
|
||||
'Content-type: text/html\r\n'
|
||||
'Cache-Control: no-cache\r\n'
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ If no test names are given, all tests are run.
|
|||
-v is incompatible with -g and does not compare test output files.
|
||||
"""
|
||||
|
||||
import sys,getopt,os,string
|
||||
import sys, getopt, os
|
||||
|
||||
import test_support
|
||||
|
||||
|
|
@ -119,10 +119,10 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
|||
print count(len(good), "test"), "OK."
|
||||
if bad:
|
||||
print count(len(bad), "test"), "failed:",
|
||||
print string.join(bad)
|
||||
print " ".join(bad)
|
||||
if skipped and not quiet:
|
||||
print count(len(skipped), "test"), "skipped:",
|
||||
print string.join(skipped)
|
||||
print " ".join(skipped)
|
||||
|
||||
return len(bad) > 0
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue