2004-08-16 19:28:42 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2010-11-05 11:27:29 +00:00
|
|
|
# Copyright (C) 2000-2010 Bastian Kleineidam
|
2004-08-16 19:28:42 +00:00
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
2009-07-24 21:58:20 +00:00
|
|
|
# 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.
|
2005-01-19 15:08:02 +00:00
|
|
|
"""
|
|
|
|
|
A gml logger.
|
|
|
|
|
"""
|
2008-06-07 13:08:54 +00:00
|
|
|
from .graph import GraphLogger
|
2004-08-16 19:28:42 +00:00
|
|
|
|
|
|
|
|
|
2008-06-07 13:08:54 +00:00
|
|
|
class GMLLogger (GraphLogger):
|
|
|
|
|
"""GML means Graph Modeling Language. Use a GML tool to see
|
|
|
|
|
the sitemap graph."""
|
2004-08-16 19:28:42 +00:00
|
|
|
|
|
|
|
|
def start_output (self):
|
2008-06-07 13:08:54 +00:00
|
|
|
"""Write start of checking info as gml comment."""
|
2004-08-25 20:08:53 +00:00
|
|
|
super(GMLLogger, self).start_output()
|
2005-05-08 20:06:40 +00:00
|
|
|
if self.has_part("intro"):
|
2010-11-01 08:58:03 +00:00
|
|
|
self.write_intro()
|
2004-10-27 22:34:50 +00:00
|
|
|
self.writeln()
|
2005-01-27 17:11:03 +00:00
|
|
|
self.writeln(u"graph [")
|
|
|
|
|
self.writeln(u" directed 1")
|
|
|
|
|
self.flush()
|
2004-08-16 19:28:42 +00:00
|
|
|
|
2004-11-25 16:20:58 +00:00
|
|
|
def comment (self, s, **args):
|
2008-06-07 13:08:54 +00:00
|
|
|
"""Write GML comment."""
|
2010-11-06 14:47:00 +00:00
|
|
|
self.writeln(s=u'comment "%s"' % s, **args)
|
2004-11-25 16:20:58 +00:00
|
|
|
|
2005-04-25 14:51:35 +00:00
|
|
|
def log_url (self, url_data):
|
2008-06-07 13:08:54 +00:00
|
|
|
"""Write one node."""
|
|
|
|
|
node = self.get_node(url_data)
|
|
|
|
|
if node:
|
2004-10-27 22:34:50 +00:00
|
|
|
self.writeln(u" node [")
|
2008-06-07 13:08:54 +00:00
|
|
|
self.writeln(u" id %d" % node["id"])
|
|
|
|
|
self.writeln(u' label "%s"' % node["label"])
|
2005-05-08 20:06:40 +00:00
|
|
|
if self.has_part("realurl"):
|
2008-06-07 13:08:54 +00:00
|
|
|
self.writeln(u' url "%s"' % node["url"])
|
|
|
|
|
if node["dltime"] >= 0 and self.has_part("dltime"):
|
|
|
|
|
self.writeln(u" dltime %d" % node["dltime"])
|
|
|
|
|
if node["dlsize"] >= 0 and self.has_part("dlsize"):
|
|
|
|
|
self.writeln(u" dlsize %d" % node["dlsize"])
|
|
|
|
|
if node["checktime"] and self.has_part("checktime"):
|
|
|
|
|
self.writeln(u" checktime %d" % node["checktime"])
|
2005-05-08 20:06:40 +00:00
|
|
|
if self.has_part("extern"):
|
2008-06-07 13:08:54 +00:00
|
|
|
self.writeln(u" extern %d" % node["extern"])
|
2004-10-27 22:34:50 +00:00
|
|
|
self.writeln(u" ]")
|
2004-08-16 19:28:42 +00:00
|
|
|
|
2008-06-07 13:08:54 +00:00
|
|
|
def write_edge (self, node):
|
|
|
|
|
"""Write one edge."""
|
|
|
|
|
self.writeln(u" edge [")
|
|
|
|
|
self.writeln(u' label "%s"' % node["edge"])
|
|
|
|
|
self.writeln(u" source %d" % self.nodes[node["parent_url"]]["id"])
|
|
|
|
|
self.writeln(u" target %d" % node["id"])
|
|
|
|
|
if self.has_part("result"):
|
|
|
|
|
self.writeln(u" valid %d" % node["valid"])
|
|
|
|
|
self.writeln(u" ]")
|
2004-08-16 19:28:42 +00:00
|
|
|
|
2008-06-07 13:08:54 +00:00
|
|
|
def end_graph (self):
|
|
|
|
|
"""Write end of graph marker."""
|
2004-10-27 22:34:50 +00:00
|
|
|
self.writeln(u"]")
|