diff --git a/doc/ldif2dot-0.1.py b/doc/ldif2dot-0.1.py index d243b531..e016d22b 100644 --- a/doc/ldif2dot-0.1.py +++ b/doc/ldif2dot-0.1.py @@ -99,8 +99,15 @@ class Element(object): Args: - dnmap: dictionary mapping dn names to Element objects """ - return ' n%d [label="%s\\l"]\n%s' % (self.index, '\\l'.join(self.attributes), self.edge(dnmap)) + def _format(attributes): + result = [TITLE_ENTRY_TEMPALTE % attributes[0]] + for attribute in attributes[1:]: + result.append(ENTRY_TEMPALTE % attribute) + + return result + + return TABLE_TEMPLATE % (self.index, '\n '.join(_format(self.attributes)), self.edge(dnmap)) class Converter(object): """An LDIF to DOT converter.""" @@ -137,8 +144,51 @@ class Converter(object): e = Element() if e.is_valid(): self._append(e) - return ('strict digraph "%s" {\n rankdir=LR\n%s}\n' - % (name, ''.join([e.dot(self.dnmap) for e in self.elements]))) + return (BASE_TEMPLATE % (name, ''.join([e.dot(self.dnmap) for e in self.elements]))) + +BASE_TEMPLATE = """\ +strict digraph "%s" { + rankdir=LR + + fontname = "Helvetica" + fontsize = 10 + splines = true + + node [ + fontname = "Helvetica" + fontsize = 10 + shape = "plaintext" + ] + + edge [ + fontname = "Helvetica" + fontsize = 10 + ] + +%s} +""" + +TABLE_TEMPLATE = """\n + n%d [label=< + + %s +
+ >] +%s +""" + +TITLE_ENTRY_TEMPALTE = """\ + + + %s + \ +""" + +ENTRY_TEMPALTE = """\ + + %s + \ +""" if __name__ == '__main__':