2004-08-16 19:28:42 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2009-01-08 14:18:03 +00:00
|
|
|
# Copyright (C) 2000-2009 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.
|
|
|
|
|
#
|
|
|
|
|
# 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.
|
2005-01-19 15:08:02 +00:00
|
|
|
"""
|
|
|
|
|
A gml logger.
|
|
|
|
|
"""
|
2004-08-16 19:28:42 +00:00
|
|
|
import time
|
2008-06-07 13:08:54 +00:00
|
|
|
from .graph import GraphLogger
|
2008-05-09 06:16:03 +00:00
|
|
|
from .. import configuration, strformat
|
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()
|
2004-08-16 19:28:42 +00:00
|
|
|
self.starttime = time.time()
|
2005-05-08 20:06:40 +00:00
|
|
|
if self.has_part("intro"):
|
2006-09-16 09:12:59 +00:00
|
|
|
self.comment(_("created by %(app)s at %(time)s") %
|
2008-05-09 06:16:03 +00:00
|
|
|
{"app": configuration.AppName,
|
|
|
|
|
"time": strformat.strtime(self.starttime)})
|
2006-02-09 07:57:22 +00:00
|
|
|
self.comment(_("Get the newest version at %(url)s") %
|
2008-05-09 06:16:03 +00:00
|
|
|
{'url': configuration.Url})
|
2006-02-09 07:57:22 +00:00
|
|
|
self.comment(_("Write comments and bugs to %(email)s") %
|
2008-05-09 06:16:03 +00:00
|
|
|
{'email': configuration.Email})
|
2004-11-25 16:20:58 +00:00
|
|
|
self.check_date()
|
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."""
|
2004-11-25 16:20:58 +00:00
|
|
|
self.write(u"# ")
|
|
|
|
|
self.writeln(s=s, **args)
|
|
|
|
|
|
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"]")
|