From 9c1f09e451245c923ce4b88d3c0d0096102f919b Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 1 May 2000 11:35:08 +0000 Subject: [PATCH] i18n support git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@79 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- Makefile | 2 +- StringUtil.py | 19 +++- Template.py | 17 +++- debian/changelog | 7 +- fintl.py | 4 +- http11lib.py | 1 + linkcheck/Config.py | 17 +++- linkcheck/FileUrlData.py | 17 ++++ linkcheck/FtpUrlData.py | 17 ++++ linkcheck/GopherUrlData.py | 17 ++++ linkcheck/HostCheckingUrlData.py | 17 ++++ linkcheck/HttpUrlData.py | 18 ++++ linkcheck/HttpsUrlData.py | 17 ++++ linkcheck/JavascriptUrlData.py | 17 ++++ linkcheck/Logging.py | 154 ++++++++++++++++++------------- linkcheck/MailtoUrlData.py | 28 ++++++ linkcheck/NntpUrlData.py | 17 ++++ linkcheck/OutputReader.py | 17 ++++ linkcheck/RobotsTxt.py | 17 ++++ linkcheck/TelnetUrlData.py | 17 ++++ linkcheck/Threader.py | 17 ++++ linkcheck/UrlData.py | 17 ++++ linkcheck/__init__.py | 16 ++++ linkcheck/lc_cgi.py | 18 +++- linkcheck/linkcheck.po | 109 ++++++++++++++++++++++ linkcheck/messages.po | 19 ---- linkchecker | 8 ++ setup.py | 17 ++++ 28 files changed, 563 insertions(+), 95 deletions(-) create mode 100644 linkcheck/linkcheck.po delete mode 100644 linkcheck/messages.po diff --git a/Makefile b/Makefile index bdda9715..a33b930c 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ install: # ha! the root option finally made it into distutils ./setup.py install --root=$(DESTDIR) # german translation mit Rezepten von Zlatko :) - msgfmt -o linkcheck.mo linkcheck/messages.po + msgfmt -o linkcheck.mo linkcheck/linkcheck.po install -c -m 644 linkcheck.mo $(DESTDIR)/usr/share/locale/de/LC_MESSAGES/ # remove following line if Distutils have script support #install -c -m 755 linkchecker $(DESTDIR)/usr/bin/ diff --git a/StringUtil.py b/StringUtil.py index 5d89a087..4e21950c 100644 --- a/StringUtil.py +++ b/StringUtil.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import string,re,sys HtmlTable = [ @@ -12,7 +29,7 @@ HtmlTable = [ ("<","<"), (">",">"), ("é","é"), - ("è","è") + ("è","è") ] SQLTable = [ diff --git a/Template.py b/Template.py index 83d8a85b..25f5ad3d 100644 --- a/Template.py +++ b/Template.py @@ -11,7 +11,7 @@ Code fragments start with a dollar sign followed either by evaluates to the str() value of the given expression example: $printit() -2) python statements +2) {python statements} append arbitrary objects to the output list Limitations: @@ -19,7 +19,11 @@ Limitations: No further syntax verification is done. 2) Parameters to function calls must not have parantheses inside. Parameters to subscriptions must not have brackets inside. - In code fragments, this is allowed, so you can use + So this is not allowed: + $func((tuple1,tuple2)) $func(map[key]) + But this is allowed: + $func(param)[1] $a[x][y][z](blubb) + In code fragments, you can write every Python code: ${OUT = OUT + trunk[idx[1](data())]} Example: @@ -27,6 +31,9 @@ import Template t = Template.Template("blabla.tmpl") open("blabla","w").write(t.fill_in({"var1":1,"var2":'hui'})) + +blabla.tmpl: +Hello, this is a demo. var1 is $var1, and var2 is $var2. """ import sys, string, re from types import StringType @@ -43,10 +50,10 @@ STRING = 3 # slicings and function calls identifier = "[a-zA-Z_][a-zA-Z0-9_]*" attributeref = identifier + "(\." + identifier + ")*" -subscription = "(\[.*?\])?" # optional -callargs = "(\(.*?\))?" # optional +subscription = "\[.*\]" +callargs = "\(.*\)" # now the whole regex -regexvar = re.compile("^" + attributeref + subscription + callargs) +regexvar = re.compile("^"+attributeref+"("+subscription+"|"+callargs+")*") class TemplateError(StandardError): diff --git a/debian/changelog b/debian/changelog index 24264e25..7ed409a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,11 +7,14 @@ linkchecker (1.2.3) unstable; urgency=low * linkchecker.bat installation support for windows * included test suite in distribution * improved mailto: link parsing - * Blacklist output support + * blacklist output support * CSV output support * SSL autodetection in setup.py + * added GPL copyright header to each of my .py files + * i18n support and german translation of the logger outputs + * use http_proxy environment variable if present - -- Bastian Kleineidam Fri, 28 Apr 2000 13:48:14 +0200 + -- Bastian Kleineidam Mon, 1 May 2000 13:03:32 +0200 linkchecker (1.2.2) unstable; urgency=low diff --git a/fintl.py b/fintl.py index 48f7815f..dc9e91c1 100644 --- a/fintl.py +++ b/fintl.py @@ -26,7 +26,7 @@ the translation into other languages. You ARE NOT REQUIRED to release the sourcecode of your program, since linking of your program against GPL code is avoided by this module. Although it is possible to use the GNU gettext library by using the -*intl.so* module written by Martin von L÷wis if this is available. But it is +*intl.so* module written by Martin von Löwis if this is available. But it is not required to use it in the first place. """ # Copyright 1999 by (Peter Funk) @@ -48,7 +48,7 @@ not required to use it in the first place. _default_localedir = '/usr/share/locale' _default_domain = 'python' -# check out, if Martin v. L÷wis 'intl' module interface to the GNU gettext +# check out, if Martin v. Löwis 'intl' module interface to the GNU gettext # library is available and use it only, if it is available: try: from intl import * diff --git a/http11lib.py b/http11lib.py index ec7932ab..c06ab447 100644 --- a/http11lib.py +++ b/http11lib.py @@ -11,6 +11,7 @@ # for tracking: # $Id$ # +# Modified by Bastian Kleineidam to squish a bug. import socket,string,mimetools,httplib diff --git a/linkcheck/Config.py b/linkcheck/Config.py index 77388ea0..33983f22 100644 --- a/linkcheck/Config.py +++ b/linkcheck/Config.py @@ -1,4 +1,19 @@ -"""Config.py in linkcheck +""" Config.py in linkcheck + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This module stores * Metadata (version, copyright, author, ...) diff --git a/linkcheck/FileUrlData.py b/linkcheck/FileUrlData.py index 46ffde8f..4b2b9358 100644 --- a/linkcheck/FileUrlData.py +++ b/linkcheck/FileUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import re,string,os,urlparse from UrlData import UrlData from os.path import normpath diff --git a/linkcheck/FtpUrlData.py b/linkcheck/FtpUrlData.py index 0895a74d..d2676bbf 100644 --- a/linkcheck/FtpUrlData.py +++ b/linkcheck/FtpUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import ftplib from UrlData import UrlData diff --git a/linkcheck/GopherUrlData.py b/linkcheck/GopherUrlData.py index f8594d3a..ff0875a9 100644 --- a/linkcheck/GopherUrlData.py +++ b/linkcheck/GopherUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" from UrlData import UrlData class GopherUrlData(UrlData): diff --git a/linkcheck/HostCheckingUrlData.py b/linkcheck/HostCheckingUrlData.py index 2a1fc1ce..5511f9b1 100644 --- a/linkcheck/HostCheckingUrlData.py +++ b/linkcheck/HostCheckingUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import socket,string from UrlData import UrlData diff --git a/linkcheck/HttpUrlData.py b/linkcheck/HttpUrlData.py index c4438d3a..8845153c 100644 --- a/linkcheck/HttpUrlData.py +++ b/linkcheck/HttpUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import http11lib,urlparse,sys,time,re from UrlData import UrlData from RobotsTxt import RobotsTxt @@ -113,6 +130,7 @@ class HttpUrlData(UrlData): def _getHttpRequest(self, method="HEAD"): "Put request and return (status code, status text, mime object)" if self.proxy: + Config.debug("Using proxy "+self.proxy) host = self.proxy+":"+`self.proxyport` else: host = self.urlTuple[1] diff --git a/linkcheck/HttpsUrlData.py b/linkcheck/HttpsUrlData.py index cd6648f0..6dd15675 100644 --- a/linkcheck/HttpsUrlData.py +++ b/linkcheck/HttpsUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" from UrlData import UrlData from HttpUrlData import HttpUrlData _supportHttps=1 diff --git a/linkcheck/JavascriptUrlData.py b/linkcheck/JavascriptUrlData.py index de442fdc..432b87b4 100644 --- a/linkcheck/JavascriptUrlData.py +++ b/linkcheck/JavascriptUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" from UrlData import UrlData class JavascriptUrlData(UrlData): diff --git a/linkcheck/Logging.py b/linkcheck/Logging.py index 952bf0aa..471b07b3 100644 --- a/linkcheck/Logging.py +++ b/linkcheck/Logging.py @@ -1,10 +1,26 @@ -"""Logger classes. +""" Logger classes. + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Every Logger has to implement the following functions: init(self) Called once to initialize the Logger. Why do we not use __init__(self)? Because we initialize the start time in init and __init__ gets not - called at the time the checking starts. + called at the time the checking starts but when the logger object is + created. newUrl(self,urlData) Called every time an url finished checking. All data we checked is in @@ -40,6 +56,8 @@ TableError="" TableOK="" RowEnd="\n" MyFont="" + +# keywords KeyWords = ["Real URL", "Result", "Base", @@ -48,12 +66,12 @@ KeyWords = ["Real URL", "Warning", "D/L Time", "Check Time", + "URL", ] -MaxIndent = max(map(len, KeyWords))+1 +MaxIndent = max(map(lambda x: len(_(x)), KeyWords))+1 Spaces = {} for key in KeyWords: - Spaces[key] = " "*(MaxIndent - len(key)) - + Spaces[key] = " "*(MaxIndent - len(_(key))) # return formatted time def _strtime(t): @@ -158,7 +176,7 @@ class HtmlLogger(StandardLogger): "

"+MyFont+Config.AppName+""+ "

"+ "
"+Config.Freeware+"

"+ - "Start checking at "+_strtime(self.starttime)+"

") + _("Start checking at ")+_strtime(self.starttime)+"

") self.fd.flush() @@ -175,38 +193,42 @@ class HtmlLogger(StandardLogger): self.fd.write(""+RowEnd) if urlData.parentName: - self.fd.write(""+MyFont+"Parent URL"+ - MyFont+""+ - urlData.parentName+" line "+str(urlData.line)+ - ""+RowEnd) + self.fd.write(""+MyFont+_("Parent URL")+ + ""+ + MyFont+""+ + urlData.parentName+" line "+str(urlData.line)+ + ""+RowEnd) if urlData.baseRef: - self.fd.write(""+MyFont+"Base"+MyFont+ - urlData.baseRef+""+RowEnd) + self.fd.write(""+MyFont+_("Base")+""+ + MyFont+urlData.baseRef+""+RowEnd) if urlData.url: - self.fd.write(""+MyFont+"Real URL"+MyFont+ - ""+ - urlData.url+""+RowEnd) + self.fd.write(""+MyFont+_("Real URL")+""+ + MyFont+""+urlData.url+""+RowEnd) if urlData.downloadtime: - self.fd.write(""+MyFont+"D/L Time"+MyFont+ - ("%.3f" % urlData.downloadtime)+" seconds"+RowEnd) + self.fd.write(""+MyFont+_("D/L Time")+""+ + MyFont+("%.3f" % urlData.downloadtime)+ + " seconds"+RowEnd) if urlData.checktime: - self.fd.write(""+MyFont+"Check Time"+ - MyFont+("%.3f" % urlData.checktime)+" seconds"+ - RowEnd) + self.fd.write(""+MyFont+_("Check Time")+ + ""+MyFont+ + ("%.3f" % urlData.checktime)+" seconds"+ + RowEnd) if urlData.infoString: - self.fd.write(""+MyFont+"Info"+MyFont+ - StringUtil.htmlify(urlData.infoString)+""+RowEnd) + self.fd.write(""+MyFont+_("Info")+""+ + MyFont+StringUtil.htmlify(urlData.infoString)+ + ""+RowEnd) if urlData.warningString: self.warnings = self.warnings+1 - self.fd.write(""+TableWarning+MyFont+"Warning"+ - TableWarning+MyFont+urlData.warningString+ - ""+RowEnd) + self.fd.write(""+TableWarning+MyFont+_("Warning")+ + ""+TableWarning+MyFont+ + urlData.warningString+""+RowEnd) if urlData.valid: - self.fd.write(""+TableOK+MyFont+"Result"+ + self.fd.write(""+TableOK+MyFont+_("Result")+""+ TableOK+MyFont+urlData.validString+""+RowEnd) else: self.errors = self.errors+1 - self.fd.write(""+TableError+MyFont+"Result"+ + self.fd.write(""+TableError+MyFont+_("Result")+""+ TableError+MyFont+urlData.errorString+""+RowEnd) self.fd.write("

") @@ -214,25 +236,25 @@ class HtmlLogger(StandardLogger): def endOfOutput(self): - self.fd.write(MyFont+"Thats it. ") + self.fd.write(MyFont+_("Thats it. ")) if self.warnings==1: - self.fd.write("1 warning, ") + self.fd.write(_("1 warning, ")) else: - self.fd.write(str(self.warnings)+" warnings, ") + self.fd.write(str(self.warnings)+_(" warnings, ")) if self.errors==1: - self.fd.write("1 error") + self.fd.write(_("1 error")) else: - self.fd.write(str(self.errors)+" errors") - self.fd.write(" found.
") + self.fd.write(str(self.errors)+_(" errors")) + self.fd.write(_(" found.")+"
") self.stoptime = time.time() - self.fd.write("Stopped checking at"+_strtime(self.stoptime)+ - (" (%.3f seconds)" % (self.stoptime - self.starttime))+ - "


"+ - MyFont+Config.HtmlAppInfo+"
Get the newest version at " - ""+Config.Url+ - ".
Write comments and bugs to "+Config.Email+ - ".
") + self.fd.write(_("Stopped checking at ")+_strtime(self.stoptime)+ + (_(" (%.3f seconds)") % (self.stoptime - self.starttime))+ + "

"+ + MyFont+Config.HtmlAppInfo+"
"+_("Get the newest version at ")+ + ""+Config.Url+ + ".
"+_("Write comments and bugs to ")+""+Config.Email+ + ".
") self.fd.flush() self.fd = None @@ -250,8 +272,8 @@ class ColoredLogger(StandardLogger): if self.currentPage != urlData.parentName: if self.prefix: self.fd.write("o\n") - self.fd.write("\nParent URL "+COL_PARENT+urlData.parentName+ - COL_RESET+"\n") + self.fd.write("\n"+_("Parent URL")+Spaces["Parent URL"]+ + COL_PARENT+urlData.parentName+COL_RESET+"\n") self.currentPage = urlData.parentName self.prefix = 1 else: @@ -264,8 +286,9 @@ class ColoredLogger(StandardLogger): self.fd.write("|\n+- ") else: self.fd.write("\n") - self.fd.write("URL "+COL_URL+urlData.urlName+COL_RESET) - if urlData.line: self.fd.write(", line "+`urlData.line`+"") + self.fd.write(_("URL")+Spaces["URL"]+COL_URL+urlData.urlName+ + COL_RESET) + if urlData.line: self.fd.write(_(", line ")+`urlData.line`+"") if urlData.cached: self.fd.write(" (cached)\n") else: @@ -274,44 +297,46 @@ class ColoredLogger(StandardLogger): if urlData.baseRef: if self.prefix: self.fd.write("| ") - self.fd.write("Base "+COL_BASE+urlData.baseRef+COL_RESET+"\n") + self.fd.write(_("Base")+Spaces["Base"]+COL_BASE+urlData.baseRef+ + COL_RESET+"\n") if urlData.url: if self.prefix: self.fd.write("| ") - self.fd.write("Real URL "+COL_REAL+urlData.url+COL_RESET+"\n") + self.fd.write(_("Real URL")+Spaces["Real URL"]+COL_REAL+ + urlData.url+COL_RESET+"\n") if urlData.downloadtime: if self.prefix: self.fd.write("| ") - self.fd.write("D/L Time "+COL_DLTIME+ - ("%.3f" % urlData.downloadtime)+" seconds"+COL_RESET+"\n") + self.fd.write(_("D/L Time")+Spaces["D/L Time"]+COL_DLTIME+ + (_("%.3f seconds") % urlData.downloadtime)+COL_RESET+"\n") if urlData.checktime: if self.prefix: self.fd.write("| ") - self.fd.write("Check Time "+COL_DLTIME+ - ("%.3f" % urlData.checktime)+" seconds"+COL_RESET+"\n") + self.fd.write(_("Check Time")+Spaces["Check Time"]+COL_DLTIME+ + (_("%.3f seconds") % urlData.checktime)+COL_RESET+"\n") if urlData.infoString: if self.prefix: - self.fd.write("| Info "+ + self.fd.write("| "+_("Info")+Spaces["Info"]+ StringUtil.indentWith(StringUtil.blocktext( - urlData.infoString, 65), "| ")) + urlData.infoString, 65), "| "+Spaces["Info"])) else: - self.fd.write("Info "+ + self.fd.write(_("Info")+Spaces["Info"]+ StringUtil.indentWith(StringUtil.blocktext( - urlData.infoString, 65), " ")) + urlData.infoString, 65), " "+Spaces["Info"])) self.fd.write(COL_RESET+"\n") if urlData.warningString: self.warnings = self.warnings+1 if self.prefix: self.fd.write("| ") - self.fd.write("Warning "+COL_WARNING+urlData.warningString+ - COL_RESET+"\n") + self.fd.write(_("Warning")+Spaces["Warning"]+COL_WARNING+ + urlData.warningString+COL_RESET+"\n") if self.prefix: self.fd.write("| ") - self.fd.write("Result ") + self.fd.write(_("Result")+Spaces["Result"]) if urlData.valid: self.fd.write(COL_VALID+urlData.validString+COL_RESET+"\n") else: @@ -337,8 +362,8 @@ class GMLLogger(StandardLogger): def init(self): self.fd.write("# created by "+Config.AppName+" at "+ _strtime(time.time())+ - "\n# you get "+Config.AppName+" at "+Config.Url+ - "\n# write comments and bugs to "+Config.Email+ + "\n# "+_("Get the newest version at ")+Config.Url+ + "\n# "+_("Write comments and bugs to ")+Config.Email+ "\ngraph [\n directed 1\n") self.fd.flush() @@ -387,8 +412,8 @@ class SQLLogger(StandardLogger): def init(self): self.fd.write("-- created by "+Config.AppName+" at "+ _strtime(time.time())+ - "\n-- you get "+Config.AppName+" at "+Config.Url+ - "\n-- write comments and bugs to "+Config.Email+"\n\n") + "\n-- "+_("Get the newest version at ")+Config.Url+ + "\n-- "+_("Write comments and bugs to ")+Config.Email+"\n\n") self.fd.flush() def newUrl(self, urlData): @@ -422,7 +447,10 @@ class BlacklistLogger: self.blacklist = {} def init(self): - """initialize the blacklist""" + """initialize the blacklist + We do nothing here because we have read the blacklist in the + linkchecker script already. + """ pass def newUrl(self, urlData): diff --git a/linkcheck/MailtoUrlData.py b/linkcheck/MailtoUrlData.py index 6aa6c3e3..1f719288 100644 --- a/linkcheck/MailtoUrlData.py +++ b/linkcheck/MailtoUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import re,socket,string,DNS,sys,Config from HostCheckingUrlData import HostCheckingUrlData from smtplib import SMTP @@ -27,6 +44,17 @@ class MailtoUrlData(HostCheckingUrlData): re.findall(adress_re, self.urlName)) def checkConnection(self, config): + """Verify a list of email adresses. If one adress fails, + the whole list will fail. + For each mail adress we check the following things: + (1) Look up the MX DNS records. If we found no MX record, + print an error. + (2) Check if one of the mail hosts accept an SMTP connection. + Check hosts with higher priority first. + If no host accepts SMTP, we print a warning. + (3) Try to verify the adress with the VRFY command. If we got + an answer, print the verified adress as an info. + """ DNS.ParseResolvConf() for user,host in self.adresses: mxrecords = DNS.mxlookup(host) diff --git a/linkcheck/NntpUrlData.py b/linkcheck/NntpUrlData.py index cb75ac1e..085ed6e8 100644 --- a/linkcheck/NntpUrlData.py +++ b/linkcheck/NntpUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import re,string,time,nntplib from HostCheckingUrlData import HostCheckingUrlData from UrlData import LinkCheckerException diff --git a/linkcheck/OutputReader.py b/linkcheck/OutputReader.py index 04479b7d..d176b466 100644 --- a/linkcheck/OutputReader.py +++ b/linkcheck/OutputReader.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import string,re import UrlData diff --git a/linkcheck/RobotsTxt.py b/linkcheck/RobotsTxt.py index 3739b075..e82453e7 100644 --- a/linkcheck/RobotsTxt.py +++ b/linkcheck/RobotsTxt.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import re,urlparse,string,httplib,urllib,sys,StringUtil,Config class RobotsTxt: diff --git a/linkcheck/TelnetUrlData.py b/linkcheck/TelnetUrlData.py index ba7a7a1f..931d7ba8 100644 --- a/linkcheck/TelnetUrlData.py +++ b/linkcheck/TelnetUrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import telnetlib,re,string from HostCheckingUrlData import HostCheckingUrlData from UrlData import LinkCheckerException diff --git a/linkcheck/Threader.py b/linkcheck/Threader.py index 774450b9..88d99af7 100644 --- a/linkcheck/Threader.py +++ b/linkcheck/Threader.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" from threading import * class Threader: diff --git a/linkcheck/UrlData.py b/linkcheck/UrlData.py index fc05df23..867ccfb7 100644 --- a/linkcheck/UrlData.py +++ b/linkcheck/UrlData.py @@ -1,3 +1,20 @@ +""" + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import sys,re,string,urlparse,urllib,time import Config,StringUtil diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py index 2512e18d..e1b1aa44 100644 --- a/linkcheck/__init__.py +++ b/linkcheck/__init__.py @@ -1,5 +1,21 @@ """__init__.py in linkcheck + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Here we find the main function to call: checkUrls. This is the only entry point into the linkcheck module and is used of course by the linkchecker script. diff --git a/linkcheck/lc_cgi.py b/linkcheck/lc_cgi.py index 925f6981..ca5c5b26 100644 --- a/linkcheck/lc_cgi.py +++ b/linkcheck/lc_cgi.py @@ -1,4 +1,20 @@ -"""common CGI functions used by the CGI scripts""" +""" common CGI functions used by the CGI scripts + Copyright (C) 2000 Bastian Kleineidam + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" import re,time,urlparse def checkform(form): diff --git a/linkcheck/linkcheck.po b/linkcheck/linkcheck.po new file mode 100644 index 00000000..5fc826f9 --- /dev/null +++ b/linkcheck/linkcheck.po @@ -0,0 +1,109 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2000-05-01 11:50+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: ENCODING\n" + +#: Logging.py:82 +msgid "Get the newest version at " +msgstr "Die neueste Version gibt es unter " + +#: Logging.py:83 +msgid "Write comments and bugs to " +msgstr "Kommentare und Fehler mailen Sie bitte an " + +#: Logging.py:84 +msgid "Start checking at " +msgstr "Beginne Prüfen am " + +#: Logging.py:89 +msgid "URL" +msgstr "URL" + +#: Logging.py:95 +msgid "Parent URL" +msgstr "Vater URL" + +#: Logging.py:96 +msgid ", line " +msgstr ", Zeile " + +#: Logging.py:99 +msgid "Base" +msgstr "Basis" + +#: Logging.py:101 +msgid "Real URL" +msgstr "Tats. URL" + +#: Logging.py:103 +msgid "D/L Time" +msgstr "D/L Zeit" + +#: Logging.py:104 Logging.py:107 +#, c-format +msgid "%.3f seconds\n" +msgstr "%.3f Sekunden\n" + +#: Logging.py:106 +msgid "Check Time" +msgstr "Prüfzeit" + +#: Logging.py:109 +msgid "Info" +msgstr "Info" + +#: Logging.py:115 +msgid "Warning" +msgstr "Warnung" + +#: Logging.py:120 +msgid "Result" +msgstr "Ergebnis" + +#: Logging.py:130 +msgid "" +"\n" +"Thats it. " +msgstr "" +"\n" +"Das wars. " + +#: Logging.py:133 +msgid "1 warning, " +msgstr "1 Warnung, " + +#: Logging.py:135 +msgid " warnings, " +msgstr " Warnungen, " + +#: Logging.py:137 +msgid "1 error" +msgstr "1 Fehler" + +#: Logging.py:139 +msgid " errors" +msgstr " Fehler" + +#: Logging.py:140 +msgid " found.\n" +msgstr " gefunden.\n" + +#: Logging.py:142 +msgid "Stopped checking at " +msgstr "Beende Prüfen am " + +#: Logging.py:143 +#, c-format +msgid " (%.3f seconds)" +msgstr " (%.3f Sekunden)" diff --git a/linkcheck/messages.po b/linkcheck/messages.po deleted file mode 100644 index 42570341..00000000 --- a/linkcheck/messages.po +++ /dev/null @@ -1,19 +0,0 @@ -# German .po file for my LinkChecker. -# Copyright (C) YEAR Free Software Foundation, Inc. -# Bastian Kleineidam , 2000. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: LinkChecker 1.2.3\n" -"POT-Creation-Date: 2000-04-30 22:43+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Bastian Kleineidam \n" -"Language-Team: German \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" -"Content-Transfer-Encoding: 8-bit\n" - -#: Logging.py:91 -msgid "Parent URL " -msgstr "Vater URL " diff --git a/linkchecker b/linkchecker index 66328b3c..68dcfc63 100755 --- a/linkchecker +++ b/linkchecker @@ -170,6 +170,14 @@ except: type, value = sys.exc_info()[:2] printUsage(value) +# check for environment variables (currently only http_proxy) +if os.environ.has_key("http_proxy"): + proxy = re.compile("(.+):(.+)").match(os.environ["http_proxy"]) + if proxy: + config["proxy"] = proxy.group(1) + config["proxyport"] = int(proxy.group(2)) + else: + config["proxy"] = os.environ["http_proxy"] # apply options and arguments _user = "anonymous" diff --git a/setup.py b/setup.py index 8fc28811..6b57dd64 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,21 @@ #!/usr/bin/env python + +# Copyright (C) 2000 Bastian Kleineidam +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + from distutils.core import setup from distutils.dist import Distribution from Template import Template