2 import pygraphviz as pgv
5 def __init__(self,token,value):
24 return self.inorder(self._root)
29 for x in self.inorder(l.children()):
32 def _add(self,trie, key, content):
36 node = Node(k,content)
41 self._add(ch.children(), key, content)
43 def add(self,key, content):
44 self._add(self._root, key, content)
46 def _graph(self, trie, G):
49 for ch in l.children():
50 G.add_edge(l.token(),ch.token())
51 self._graph(l.children(), G)
54 G = pgv.AGraph(directed=True)
57 G.add_edge("sitemap",ch.token())
58 self._graph(self._root, G)
63 def _menu(self, trie, lang, page, css, subdir):
64 html = "<ul%s>\n" % css
67 p = l.value().page(lang)
69 sel = ' class="selected"'
71 html += '<li%s><a href="%s%s">%s</a>\n' \
72 % (sel,subdir,l.value().link(),p.menu())
74 html += '<li%s><a href="%s%s.en" hreflang="en">%s</a>*\n' \
75 % (sel,subdir,l.value().link(), l.value().page('en').menu())
77 html += self._menu(l.children(), lang, page, "", subdir)
82 def menu(self,lang,page,cssclass,subdir):
85 css = ' class="'+cssclass+'"'
86 return self._menu(self._root, lang, page, css, subdir)