mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-24 09:50:23 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@59 e7d03fd6-7b0d-0410-9947-9c21f3af8025
33 lines
1 KiB
Python
33 lines
1 KiB
Python
import re,string,time,nntplib
|
|
from HostCheckingUrlData import HostCheckingUrlData
|
|
from UrlData import LinkCheckerException
|
|
|
|
nntp_re = re.compile("^news:[\w.\-]+$")
|
|
|
|
class NntpUrlData(HostCheckingUrlData):
|
|
"Url link with NNTP scheme"
|
|
|
|
def buildUrl(self):
|
|
HostCheckingUrlData.buildUrl(self)
|
|
if not nntp_re.match(self.urlName):
|
|
raise LinkCheckerException, "Illegal NNTP link syntax"
|
|
self.host = string.lower(self.urlName[5:])
|
|
|
|
|
|
def checkConnection(self, config):
|
|
if not config["nntpserver"]:
|
|
self.setWarning("No NNTP server specified, checked only syntax")
|
|
config.connectNntp()
|
|
nntp = config["nntp"]
|
|
resp,count,first,last,name = nntp.group(self.host)
|
|
self.setInfo("Group %s has %s articles, range %s to %s" % \
|
|
(name, count, first, last))
|
|
|
|
|
|
def getCacheKey(self):
|
|
return "news:"+HostCheckingUrlData.getCacheKey(self)
|
|
|
|
|
|
def __str__(self):
|
|
return "NNTP link\n"+HostCheckingUrlData.__str__(self)
|
|
|