From d5a59e7e9ef3fdfc7dc7d4a80cbde6b524c5100b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 24 May 2011 12:32:01 -0700 Subject: ovsdb: Annotate E-R diagram with number of allowed values. This makes the diagram even more informative. --- ovsdb/ovsdb-dot.in | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'ovsdb/ovsdb-dot.in') diff --git a/ovsdb/ovsdb-dot.in b/ovsdb/ovsdb-dot.in index d41728627..30da1cb35 100755 --- a/ovsdb/ovsdb-dot.in +++ b/ovsdb/ovsdb-dot.in @@ -10,10 +10,25 @@ import sys argv0 = sys.argv[0] -def printEdge(tableName, baseType, label): +def printEdge(tableName, type, baseType, label): if baseType.ref_table: + if type.n_min == 0: + if type.n_max == 1: + arity = "?" + elif type.n_max == sys.maxint: + arity = "*" + else: + arity = "{,%d}" % type.n_max + elif type.n_min == 1: + if type.n_max == 1: + arity = "" + elif type.n_max == sys.maxint: + arity = "+" + else: + arity = "{1,%d}" % type.n_max + options = {} - options['label'] = '"%s"' % label + options['label'] = '"%s%s"' % (label, arity) if baseType.ref_type == 'weak': options['constraint'] = 'false' options['style'] = 'dotted' @@ -39,10 +54,10 @@ def schemaToDot(schemaFile): ', '.join(['%s=%s' % (k,v) for k,v in options.items()])) for columnName, column in table.columns.iteritems(): if column.type.value: - printEdge(tableName, column.type.key, "%s key" % columnName) - printEdge(tableName, column.type.value, "%s value" % columnName) + printEdge(tableName, column.type, column.type.key, "%s key" % columnName) + printEdge(tableName, column.type, column.type.value, "%s value" % columnName) else: - printEdge(tableName, column.type.key, columnName) + printEdge(tableName, column.type, column.type.key, columnName) print "}"; def usage(): -- cgit v1.2.1