diff --git a/linkcheck/gui/__init__.py b/linkcheck/gui/__init__.py index 49a488d7..eb1bccd1 100644 --- a/linkcheck/gui/__init__.py +++ b/linkcheck/gui/__init__.py @@ -20,7 +20,8 @@ import sys import webbrowser from PyQt4 import QtCore, QtGui from .linkchecker_ui_main import Ui_MainWindow -from .properties import set_properties, set_statistics +from .properties import set_properties, clear_properties +from .statistics import set_statistics, clear_statistics from .progress import LinkCheckerProgress, StatusLogger from .debug import LinkCheckerDebug from .logger import GuiLogger, GuiLogHandler @@ -255,6 +256,8 @@ to improve %(appname)s even more! def check (self): """Check given URL.""" self.model.clear() + clear_properties(self) + clear_statistics(self) self.set_config() aggregate = director.get_aggregate(self.config) url = self.get_url() diff --git a/linkcheck/gui/properties.py b/linkcheck/gui/properties.py index 81149f9b..c226db6e 100644 --- a/linkcheck/gui/properties.py +++ b/linkcheck/gui/properties.py @@ -53,16 +53,16 @@ def set_properties (widget, data): widget.prop_result.setText(result) -def set_statistics (widget, statistics): - widget.stats_domains.setText(u"%d" % len(statistics.domains)) - widget.stats_url_minlen.setText(u"%d" % statistics.min_url_length) - widget.stats_url_maxlen.setText(u"%d" % statistics.max_url_length) - widget.stats_url_avglen.setText(u"%d" % statistics.avg_url_length) - widget.stats_valid_urls.setText(u"%d" % (statistics.number - statistics.errors)) - widget.stats_invalid_urls.setText(u"%d" % statistics.errors) - widget.stats_warnings.setText(u"%d" % statistics.warnings) - for key, value in statistics.link_types.items(): - getattr(widget, "stats_content_%s"%key).setText(u"%d" % value) +def clear_properties (widget): + widget.prop_url.setText(u"") + widget.prop_parenturl.setText(u"") + widget.prop_base.setText(u"") + widget.prop_checktime.setText(u"") + widget.prop_dltime.setText(u"") + widget.prop_size.setText(u"") + widget.prop_info.setText(u"") + widget.prop_warning.setText(u"") + widget.prop_result.setText(u"") def wrap (lines, width): diff --git a/linkcheck/gui/statistics.py b/linkcheck/gui/statistics.py new file mode 100644 index 00000000..2f0481df --- /dev/null +++ b/linkcheck/gui/statistics.py @@ -0,0 +1,41 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2010 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from ..logger import ContentTypes + +def set_statistics (widget, statistics): + widget.stats_domains.setText(u"%d" % len(statistics.domains)) + widget.stats_url_minlen.setText(u"%d" % statistics.min_url_length) + widget.stats_url_maxlen.setText(u"%d" % statistics.max_url_length) + widget.stats_url_avglen.setText(u"%d" % statistics.avg_url_length) + widget.stats_valid_urls.setText(u"%d" % (statistics.number - statistics.errors)) + widget.stats_invalid_urls.setText(u"%d" % statistics.errors) + widget.stats_warnings.setText(u"%d" % statistics.warnings) + for key, value in statistics.link_types.items(): + getattr(widget, "stats_content_%s"%key).setText(u"%d" % value) + + +def clear_statistics (widget): + widget.stats_domains.setText(u"") + widget.stats_url_minlen.setText(u"") + widget.stats_url_maxlen.setText(u"") + widget.stats_url_avglen.setText(u"") + widget.stats_valid_urls.setText(u"") + widget.stats_invalid_urls.setText(u"") + widget.stats_warnings.setText(u"") + for key in ContentTypes: + getattr(widget, "stats_content_%s"%key).setText(u"") diff --git a/linkcheck/logger/__init__.py b/linkcheck/logger/__init__.py index 1ad1dd9f..84e93dec 100644 --- a/linkcheck/logger/__init__.py +++ b/linkcheck/logger/__init__.py @@ -44,6 +44,15 @@ Fields = dict( ) del _ +ContentTypes = dict( + image=0, + text=0, + video=0, + audio=0, + application=0, + mail=0, + other=0, +) class LogStatistics (object): """Gather log statistics: @@ -65,15 +74,7 @@ class LogStatistics (object): # number of warnings that were printed self.warnings_printed = 0 self.domains = set() - self.link_types = dict( - image=0, - text=0, - video=0, - audio=0, - application=0, - mail=0, - other=0, - ) + self.link_types = ContentTypes.copy() self.max_url_length = 0 self.min_url_length = 0 self.avg_url_length = 0.0