Thanks for review, Jorgen!
I figured I had also got the order of edges incorrectly: i.e. done "$key -> $signedby" instead of "$signedby -> $key". It does not really matter for strong set, but inconvenient anyway. There's also fix for escaping quotes in names, and cleaner formatting in newer patch. "dot" does not complain anymore, though dying with out-of-memory because of rather huge graph (I use Gephi instead to operate on graphs of these sizes).
-Aleksey.
On Tue, Jan 3, 2012 at 2:15 AM, Jorgen Cederlof jc@lysator.liu.se wrote:
On Mon, Dec 26, 2011 at 11:31:26 +0400, Aleksey Shipilev wrote:
Hi guys,
I was needing to build the graph for Web-of-Trust, and spend some time downloading keys from keyserver and rendering those with sig2dot. It was before I came across Wotsap, and figured that all the graph info I need is actually there in convenient form. However, I would like to explore the graph before rendering it, so converting .wot to some other graph interchange format is a nice to have feature. I had hacked around wotsap to build .dot file from .wot file, please see attached patch.
I would greatly appreciate if this feature would become the part of your distribution of Wotsap. The code is really straight-forward, but review is appreciated nevertheless.
Thanks, Aleksey.
Thanks Aleksey!
This looks useful. I will include this in the distribution.
The patch looks mostly fine, but there is a bug. When I run this against the latest .wot and feed the result to 'dot', I get this:
Error: /tmp/foo.dot:23939: syntax error near line 23939 context: "EE8624F1" [label="Do not use my >>> "jet. <<< uk" email address."] Warning: /tmp/foo.dot:114982: string ran past end of line Warning: /tmp/foo.dot:184952: string ran past end of line Warning: /tmp/foo.dot:273216: string ran past end of line Warning: /tmp/foo.dot:309838: string ran past end of line
All those lines seems to be cases where the label contains quotation marks. Those will need to be quoted somehow. Maybe other characters need to be quoted too?
While you're editing there, can you change to something like
'"%s" [label="%s"]' % (...)
? I find that much more readable.
Jörgen
diff -r 08f3e57370dc -r 27987afe8330 wotsap --- a/wotsap Mon Dec 26 09:22:45 2011 +0300 +++ b/wotsap Mon Dec 26 10:24:20 2011 +0300 @@ -66,6 +66,7 @@ import math import re import random +import codecs
# How cert levels are presented clascii = "abcd0123?!U" @@ -1137,6 +1138,18 @@ for line in print_key(wot, key, u"", u" "): yield line
+def print_dot(wot):
- """Print all keys and signatures in dot file."""
- yield "digraph "Keyring signatures" {"
- for key in xrange(len(wot.keys)):
- yield """ + key2str(wot.keys[key]) + "" [label="" + wot.names[key] + ""]";
- sigs = wot.sigs[DN][key]
- siglist = list(sigs)
- for signedby in siglist:
- yield """ + key2str(wot.keys[key]) + "" -> "" + key2str(wot.keys[signedby]) + """
- yield "}"
# XXX If onlykeys, show differences in both directions? def diff_wots(wot0, wot1, onlykeys=None): """Print differences between two web-of-trusts.""" @@ -1562,6 +1575,7 @@ u" Point it to the .pil file, with the .pbm file in the same\n" \ u" directory. Defaults to ~/.wotsapfont.pil\n" \ u" -p, --print Print the whole web-of-trust in human readable format.\n" \
- u" -e, --export=FILE Export the whole web-of-trust to DOT file.\n" \
u" -D, --print-debug Print the debug information in the .wot file.\n" \ u" -d, --diff=FILE Print all differences between two .wot files.\n" \ u" -M, --msd Just show MSD for key.\n" \ @@ -1587,10 +1601,10 @@ else: gopt = getopt.getopt opts, args = gopt(argv[1:],
- "hw:m:go:O:F:pDd:MW:r:",
- "hw:m:go:O:F:pDd:MW:r:e:",
["help", "wot=", "modify=", "group", "png=", "show-png=", "font=", "print", "print-debug", "diff=", "version",
- "msd", "wanted=", "restrict="])
- "msd", "wanted=", "restrict=", "export="])
except getopt.GetoptError: usage(2)
@@ -1606,6 +1620,7 @@ prnt = 0 prnt_debug = 0 diff = None
- dot = None
for o, a in opts: if o in ("-h", "--help"): usage(0) @@ -1625,6 +1640,8 @@ fontfile = a elif o in ("-p", "--print"): prnt=1
- elif o in ("-e", "--export"):
- dot = a
elif o in ("-D", "--print-debug"): prnt_debug=1 elif o in ("-d", "--diff"): @@ -1725,6 +1742,13 @@ print line.encode(encoding, 'replace') sys.exit(0)
- if dot:
- fdot = codecs.open(dot, encoding='utf-8', mode='w')
- for line in print_dot(wot):
- print >>fdot, line
- fdot.close
- sys.exit(0)
if top and bottom: try: web = wot.findpaths(bottom, top, modstr=modifystr)
Wotsap-dev mailing list Wotsap-dev@lists.lysator.liu.se http://lists.lysator.liu.se/mailman/listinfo/wotsap-dev
wotsap-dev@lists.lysator.liu.se