mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-03 04:14:43 +00:00
clean up raise calls
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2294 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
6ceb80689a
commit
44075c47bf
11 changed files with 42 additions and 42 deletions
|
|
@ -106,12 +106,12 @@ class FtpUrl (urlbase.UrlBase, proxysupport.ProxySupport):
|
|||
self.url_connection.login(_user, _password)
|
||||
except EOFError, msg:
|
||||
msg = str(msg)
|
||||
raise linkcheck.LinkCheckerError(
|
||||
_("Remote host has closed connection: %r") % msg)
|
||||
raise linkcheck.LinkCheckerError, \
|
||||
_("Remote host has closed connection: %r") % msg
|
||||
if not self.url_connection.getwelcome():
|
||||
self.close_connection()
|
||||
raise linkcheck.LinkCheckerError(
|
||||
_("Got no answer from FTP server"))
|
||||
raise linkcheck.LinkCheckerError, \
|
||||
_("Got no answer from FTP server")
|
||||
# don't set info anymore, this may change every time we log in
|
||||
#self.add_info(info)
|
||||
|
||||
|
|
|
|||
|
|
@ -501,8 +501,8 @@ class HttpUrl (urlbase.UrlBase, proxysupport.ProxySupport):
|
|||
elif scheme == "https" and supportHttps:
|
||||
h = linkcheck.httplib2.HTTPSConnection(host)
|
||||
else:
|
||||
raise linkcheck.LinkCheckerError(
|
||||
_("Unsupported HTTP url scheme %r") % scheme)
|
||||
raise linkcheck.LinkCheckerError, \
|
||||
_("Unsupported HTTP url scheme %r") % scheme
|
||||
if self.consumer.config.get("debug"):
|
||||
h.set_debuglevel(1)
|
||||
h.connect()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ def _split_address (address):
|
|||
return tuple(split)
|
||||
if len(split) == 1:
|
||||
return (split[0], "localhost")
|
||||
raise linkcheck.LinkCheckerError(_("Could not split the mail address"))
|
||||
raise linkcheck.LinkCheckerError, _("Could not split the mail address")
|
||||
|
||||
|
||||
class MailtoUrl (urlbase.UrlBase):
|
||||
|
|
@ -72,7 +72,7 @@ class MailtoUrl (urlbase.UrlBase):
|
|||
for name, addr in self.addresses:
|
||||
username, domain = _split_address(addr)
|
||||
if not linkcheck.url.is_safe_domain(domain):
|
||||
raise linkcheck.LinkCheckerError(_("Invalid mail syntax"))
|
||||
raise linkcheck.LinkCheckerError, _("Invalid mail syntax")
|
||||
linkcheck.log.debug(linkcheck.LOG_CHECK, "addresses: %s",
|
||||
self.addresses)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ class NntpUrl (urlbase.UrlBase):
|
|||
else:
|
||||
raise
|
||||
if nntp is None:
|
||||
raise linkcheck.LinkCheckerError(
|
||||
_("NTTP server too busy; tried more than %d times.") % tries)
|
||||
raise linkcheck.LinkCheckerError, \
|
||||
_("NTTP server too busy; tried more than %d times.") % tries
|
||||
if value is not None:
|
||||
self.add_warning(_("NNTP busy: %s.") % str(value))
|
||||
return nntp
|
||||
|
|
|
|||
|
|
@ -317,8 +317,8 @@ class UrlBase (object):
|
|||
self.host, self.port = urllib.splitport(host)
|
||||
if self.port is not None:
|
||||
if not linkcheck.url.is_numeric_port(self.port):
|
||||
raise linkcheck.LinkCheckerError(
|
||||
_("URL has invalid port %r") % str(self.port))
|
||||
raise linkcheck.LinkCheckerError, \
|
||||
_("URL has invalid port %r") % str(self.port)
|
||||
self.port = int(self.port)
|
||||
|
||||
def check (self):
|
||||
|
|
@ -334,7 +334,7 @@ class UrlBase (object):
|
|||
# error: (4, 'Interrupted system call')
|
||||
etype, value = sys.exc_info()[:2]
|
||||
if etype == 4:
|
||||
raise KeyboardInterrupt(value)
|
||||
raise KeyboardInterrupt, value
|
||||
else:
|
||||
raise
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ class FCGI (object):
|
|||
self.conn, addr = _sock.accept()
|
||||
# Check if the connection is from a legal address
|
||||
if good_addrs != None and addr not in good_addrs:
|
||||
raise error('Connection from invalid server!')
|
||||
raise error, 'Connection from invalid server!'
|
||||
|
||||
stdin = data = ""
|
||||
self.env = {}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class HTTPResponse:
|
|||
if not line:
|
||||
# Presumably, the server closed the connection before
|
||||
# sending a valid response.
|
||||
raise BadStatusLine(line)
|
||||
raise BadStatusLine, line
|
||||
try:
|
||||
[version, status, reason] = line.split(None, 2)
|
||||
except ValueError:
|
||||
|
|
@ -309,7 +309,7 @@ class HTTPResponse:
|
|||
if not version.startswith('HTTP/'):
|
||||
if self.strict:
|
||||
self.close()
|
||||
raise BadStatusLine(line)
|
||||
raise BadStatusLine, line
|
||||
else:
|
||||
# assume it's a Simple-Response from an 0.9 server
|
||||
self.fp = LineAndFileWrapper(line, self.fp)
|
||||
|
|
@ -319,9 +319,9 @@ class HTTPResponse:
|
|||
try:
|
||||
status = int(status)
|
||||
if status < 100 or status > 999:
|
||||
raise BadStatusLine(line)
|
||||
raise BadStatusLine, line
|
||||
except ValueError:
|
||||
raise BadStatusLine(line)
|
||||
raise BadStatusLine, line
|
||||
return version, status, reason
|
||||
|
||||
def begin(self):
|
||||
|
|
@ -351,7 +351,7 @@ class HTTPResponse:
|
|||
elif version == 'HTTP/0.9':
|
||||
self.version = 9
|
||||
else:
|
||||
raise UnknownProtocol(version)
|
||||
raise UnknownProtocol, version
|
||||
|
||||
if self.version == 9:
|
||||
self.chunked = 0
|
||||
|
|
@ -496,7 +496,7 @@ class HTTPResponse:
|
|||
try:
|
||||
chunk_left = int(line, 16)
|
||||
except ValueError, msg:
|
||||
raise IncompleteRead("Invalid chunk length at %r" % line)
|
||||
raise IncompleteRead, "Invalid chunk length at %r" % line
|
||||
if chunk_left == 0:
|
||||
break
|
||||
if amt is None:
|
||||
|
|
@ -548,20 +548,20 @@ class HTTPResponse:
|
|||
while amt > 0:
|
||||
chunk = self.fp.read(amt)
|
||||
if not chunk:
|
||||
raise IncompleteRead(s)
|
||||
raise IncompleteRead, s
|
||||
s += chunk
|
||||
amt -= len(chunk)
|
||||
return s
|
||||
|
||||
def getheader(self, name, default=None):
|
||||
if self.msg is None:
|
||||
raise ResponseNotReady()
|
||||
raise ResponseNotReady
|
||||
return self.msg.getheader(name, default)
|
||||
|
||||
def getheaders(self):
|
||||
"""Return list of (header, value) tuples."""
|
||||
if self.msg is None:
|
||||
raise ResponseNotReady()
|
||||
raise ResponseNotReady
|
||||
return self.msg.items()
|
||||
|
||||
|
||||
|
|
@ -595,7 +595,7 @@ class HTTPConnection:
|
|||
try:
|
||||
port = int(host[i+1:])
|
||||
except ValueError:
|
||||
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
|
||||
raise InvalidURL, "nonnumeric port: '%s'" % host[i+1:]
|
||||
host = host[:i]
|
||||
else:
|
||||
port = self.default_port
|
||||
|
|
@ -645,7 +645,7 @@ class HTTPConnection:
|
|||
if self.auto_open:
|
||||
self.connect()
|
||||
else:
|
||||
raise NotConnected()
|
||||
raise NotConnected
|
||||
|
||||
# send the data to the server. if we get a broken pipe, then close
|
||||
# the socket. we want to reconnect when somebody tries to send again.
|
||||
|
|
@ -714,7 +714,7 @@ class HTTPConnection:
|
|||
if self.__state == _CS_IDLE:
|
||||
self.__state = _CS_REQ_STARTED
|
||||
else:
|
||||
raise CannotSendRequest()
|
||||
raise CannotSendRequest
|
||||
|
||||
# Save the method we use, we need it later in the response phase
|
||||
self._method = method
|
||||
|
|
@ -782,7 +782,7 @@ class HTTPConnection:
|
|||
For example: h.putheader('Accept', 'text/html')
|
||||
"""
|
||||
if self.__state != _CS_REQ_STARTED:
|
||||
raise CannotSendHeader()
|
||||
raise CannotSendHeader
|
||||
|
||||
str = '%s: %s' % (header, value)
|
||||
self._output(str)
|
||||
|
|
@ -793,7 +793,7 @@ class HTTPConnection:
|
|||
if self.__state == _CS_REQ_STARTED:
|
||||
self.__state = _CS_REQ_SENT
|
||||
else:
|
||||
raise CannotSendHeader()
|
||||
raise CannotSendHeader
|
||||
|
||||
self._send_output()
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ class HTTPConnection:
|
|||
# isclosed() status to become true.
|
||||
#
|
||||
if self.__state != _CS_REQ_SENT or self.__response:
|
||||
raise ResponseNotReady()
|
||||
raise ResponseNotReady
|
||||
|
||||
if self.debuglevel > 0:
|
||||
response = self.response_class(self.sock, self.debuglevel,
|
||||
|
|
@ -1026,7 +1026,7 @@ class FakeSocket(SharedSocketClient):
|
|||
|
||||
class _closedsocket:
|
||||
def __getattr__(self, name):
|
||||
raise error(9, 'Bad file descriptor')
|
||||
raise error, (9, 'Bad file descriptor')
|
||||
|
||||
def __init__(self, sock, ssl):
|
||||
sock = SharedSocket(sock)
|
||||
|
|
@ -1039,7 +1039,7 @@ class FakeSocket(SharedSocketClient):
|
|||
|
||||
def makefile(self, mode, bufsize=None):
|
||||
if mode != 'r' and mode != 'rb':
|
||||
raise UnimplementedFileMode()
|
||||
raise UnimplementedFileMode
|
||||
return SSLFile(self._shared, self._ssl, bufsize)
|
||||
|
||||
def send(self, stuff, flags = 0):
|
||||
|
|
|
|||
|
|
@ -130,26 +130,26 @@ def checkform (form):
|
|||
os.environ['LC_MESSAGES'] = lang
|
||||
linkcheck.init_i18n()
|
||||
else:
|
||||
raise FormError(_("unsupported language"))
|
||||
raise FormError, _("unsupported language")
|
||||
# check url syntax
|
||||
if form.has_key("url"):
|
||||
url = form["url"].value
|
||||
if not url or url == "http://":
|
||||
raise FormError(_("empty url was given"))
|
||||
raise FormError, _("empty url was given")
|
||||
if not linkcheck.url.is_safe_url(url):
|
||||
raise FormError(_("disallowed url was given"))
|
||||
raise FormError, _("disallowed url was given")
|
||||
else:
|
||||
raise FormError(_("no url was given"))
|
||||
raise FormError, _("no url was given")
|
||||
# check recursion level
|
||||
if form.has_key("level"):
|
||||
level = form["level"].value
|
||||
if not _is_level(level):
|
||||
raise FormError(_("invalid recursion level"))
|
||||
raise FormError, _("invalid recursion level")
|
||||
# check options
|
||||
for option in ("externstrictall", "anchors", "errors", "intern"):
|
||||
if form.has_key(option):
|
||||
if not form[option].value == "on":
|
||||
raise FormError(_("invalid %s option syntax") % option)
|
||||
raise FormError, _("invalid %s option syntax") % option
|
||||
|
||||
def logit (form, env):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class Logger (object):
|
|||
@rtype: string
|
||||
"""
|
||||
if not isinstance(s, unicode):
|
||||
raise ValueError("tried to encode non-unicode string %r" % s)
|
||||
raise ValueError, "tried to encode non-unicode string %r" % s
|
||||
return s.encode(self.output_encoding, "replace")
|
||||
|
||||
def check_date (self):
|
||||
|
|
@ -130,7 +130,7 @@ class Logger (object):
|
|||
Write string to output descriptor.
|
||||
"""
|
||||
if self.fd is None:
|
||||
raise ValueError("write to non-file")
|
||||
raise ValueError, "write to non-file"
|
||||
self.fd.write(self.encode(s), **args)
|
||||
|
||||
def writeln (self, s=u"", **args):
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class MyHTTPRedirectHandler (urllib2.HTTPRedirectHandler):
|
|||
visited = new.redirect_dict = req.redirect_dict
|
||||
if (visited.get(newurl, 0) >= self.max_repeats or
|
||||
len(visited) >= self.max_redirections):
|
||||
raise HTTPError(req.get_full_url(), code,
|
||||
self.inf_msg + msg, headers, fp)
|
||||
raise HTTPError, (req.get_full_url(), code,
|
||||
self.inf_msg + msg, headers, fp)
|
||||
else:
|
||||
visited = new.redirect_dict = req.redirect_dict = {}
|
||||
visited[newurl] = visited.get(newurl, 0) + 1
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ def strsize (b):
|
|||
raises a value error.
|
||||
"""
|
||||
if b < 0:
|
||||
raise ValueError("Invalid negative byte number")
|
||||
raise ValueError, "Invalid negative byte number"
|
||||
if b == 1:
|
||||
return u"%d Byte" % b
|
||||
if b < 1024:
|
||||
|
|
|
|||
Loading…
Reference in a new issue