2000-11-11 00:38:04 +00:00
|
|
|
""" linkcheck/__init__.py
|
2000-04-10 16:58:05 +00:00
|
|
|
|
2000-05-01 11:35:08 +00:00
|
|
|
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.
|
|
|
|
|
|
2000-04-10 16:58:05 +00:00
|
|
|
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.
|
|
|
|
|
"""
|
2000-06-10 18:06:43 +00:00
|
|
|
class error(Exception):
|
|
|
|
|
pass
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2000-04-30 22:34:43 +00:00
|
|
|
# i18n suppport
|
2000-12-22 16:25:32 +00:00
|
|
|
LANG="EN" # default language (used for HTML output)
|
2000-10-10 14:59:41 +00:00
|
|
|
import LinkCheckerConf
|
2000-04-30 22:34:43 +00:00
|
|
|
try:
|
2000-12-22 16:25:32 +00:00
|
|
|
import fintl,os,string
|
2000-11-09 12:02:38 +00:00
|
|
|
gettext = fintl.gettext
|
2000-05-22 12:00:54 +00:00
|
|
|
domain = 'linkcheck'
|
2000-10-10 14:59:41 +00:00
|
|
|
localedir = os.path.join(LinkCheckerConf.install_data, 'locale')
|
2000-11-09 12:02:38 +00:00
|
|
|
fintl.bindtextdomain(domain, localedir)
|
|
|
|
|
fintl.textdomain(domain)
|
2000-12-22 16:25:32 +00:00
|
|
|
languages = []
|
|
|
|
|
for envvar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
|
|
|
|
|
if os.environ.has_key(envvar):
|
|
|
|
|
languages = string.split(os.environ[envvar], ':')
|
|
|
|
|
break
|
|
|
|
|
if languages:
|
|
|
|
|
LANG=string.upper(languages[0])
|
|
|
|
|
|
2000-04-30 22:34:43 +00:00
|
|
|
except ImportError:
|
|
|
|
|
def gettext(msg):
|
|
|
|
|
return msg
|
2000-05-28 23:49:42 +00:00
|
|
|
# set _ as an alias for gettext
|
|
|
|
|
_ = gettext
|
|
|
|
|
|
2000-05-16 15:31:19 +00:00
|
|
|
import Config,UrlData,sys,lc_cgi
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
def checkUrls(config = Config.Configuration()):
|
2000-04-10 16:58:05 +00:00
|
|
|
""" checkUrls gets a complete configuration object as parameter where all
|
|
|
|
|
runtime-dependent options are stored.
|
|
|
|
|
If you call checkUrls more than once, you can specify different
|
|
|
|
|
configurations.
|
|
|
|
|
|
|
|
|
|
In the config object there are functions to get a new URL (getUrl) and
|
|
|
|
|
to check it (checkUrl).
|
|
|
|
|
"""
|
2000-02-26 10:24:46 +00:00
|
|
|
config.log_init()
|
|
|
|
|
try:
|
|
|
|
|
while not config.finished():
|
|
|
|
|
if config.hasMoreUrls():
|
|
|
|
|
config.checkUrl(config.getUrl())
|
2001-01-06 18:00:43 +00:00
|
|
|
config.log_endOfOutput()
|
2000-02-26 10:24:46 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
config.finish()
|
|
|
|
|
config.log_endOfOutput()
|
2001-01-06 18:00:43 +00:00
|
|
|
sys.stderr.write("linkcheck: warning: keyboard interrupt\n")
|