mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-26 02:40:23 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1375 e7d03fd6-7b0d-0410-9947-9c21f3af8025
81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
# -*- coding: iso-8859-1 -*-
|
|
# Copyright (C) 2000-2004 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 bk.i18n
|
|
|
|
|
|
class Logger (object):
|
|
|
|
Fields = {
|
|
"realurl": bk.i18n._("Real URL"),
|
|
"result": bk.i18n._("Result"),
|
|
"base": bk.i18n._("Base"),
|
|
"name": bk.i18n._("Name"),
|
|
"parenturl": bk.i18n._("Parent URL"),
|
|
"extern": bk.i18n._("Extern"),
|
|
"info": bk.i18n._("Info"),
|
|
"warning": bk.i18n._("Warning"),
|
|
"dltime": bk.i18n._("D/L Time"),
|
|
"dlsize": bk.i18n._("D/L Size"),
|
|
"checktime": bk.i18n._("Check Time"),
|
|
"url": bk.i18n._("URL"),
|
|
}
|
|
|
|
def __init__ (self, **args):
|
|
self.logfields = None # log all fields
|
|
if args.has_key('fields'):
|
|
if "all" not in args['fields']:
|
|
self.logfields = args['fields']
|
|
|
|
def has_field (self, name):
|
|
if self.logfields is None:
|
|
# log all fields
|
|
return True
|
|
return name in self.logfields
|
|
|
|
def field (self, name):
|
|
"""return translated field name"""
|
|
# XXX i18nreal._(self.Fields[name])
|
|
return self.Fields[name]
|
|
|
|
def spaces (self, name):
|
|
return self.logspaces[name]
|
|
|
|
def init (self):
|
|
# map with spaces between field name and value
|
|
self.logspaces = {}
|
|
if self.logfields is None:
|
|
fields = self.Fields.keys()
|
|
else:
|
|
fields = self.logfields
|
|
values = [self.field(x) for x in fields]
|
|
# maximum indent for localized log field names
|
|
self.max_indent = max(map(lambda x: len(x), values))+1
|
|
for key in fields:
|
|
self.logspaces[key] = " "*(self.max_indent - len(self.field(key)))
|
|
|
|
def newUrl (self, urlData):
|
|
raise Exception, "abstract function"
|
|
|
|
def endOfOutput (self, linknumber=-1):
|
|
raise Exception, "abstract function"
|
|
|
|
def __str__ (self):
|
|
return self.__class__.__name__
|
|
|
|
def __repr__ (self):
|
|
return repr(self.__class__.__name__)
|