Mercurial > p > roundup > code
annotate scripts/schema_diagram.py @ 8566:e4191aa7b402 default tip
doc: issue2551415 correct doc for change input->input_payload
in 2.5 the rest interface changed a variable name from input to
input_payload. An earlier commit changed the rest docs. This commit
adds an item for it to the upgrading 2.4.0->2.5.0 section. Also cross
reference added to the rest docs with the updated examples.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 09 Apr 2026 00:19:06 -0400 |
| parents | 9c3ec0a5c7fc |
| children |
| rev | line source |
|---|---|
| 1166 | 1 #! /usr/bin/python |
| 2 # | |
| 3 # Schema diagram generator contributed by Stefan Seefeld of the fresco | |
| 4 # project http://www.fresco.org/. | |
| 5 # | |
| 6 # It generates a 'dot file' that is then fed into the 'dot' | |
| 7 # tool (http://www.graphviz.org) to generate a graph: | |
| 8 # | |
| 9 # %> ./schema.py | |
| 10 # %> dot -Tps schema.dot -o schema.ps | |
| 11 # %> gv schema.ps | |
| 12 # | |
| 13 import sys | |
| 14 import roundup.instance | |
| 15 | |
| 16 # open the instance | |
| 17 instance = roundup.instance.open(sys.argv[1]) | |
| 18 db = instance.open() | |
| 19 | |
| 20 # diagram preamble | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
21 print('digraph schema {') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
22 print('size="8,6"') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
23 print('node [shape="record" bgcolor="#ffe4c4" style=filled]') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
24 print('edge [taillabel="1" headlabel="1" dir=back arrowtail=ediamond]') |
| 1166 | 25 |
| 26 # get all the classes | |
|
5395
23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5376
diff
changeset
|
27 types = list(db.classes.keys()) |
| 1166 | 28 |
| 29 # one record node per class | |
| 30 for i in range(len(types)): | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
31 print('node%d [label=\"{%s|}"]'%(i, types[i])) |
| 1166 | 32 |
| 33 # now draw in the relations | |
| 34 for name in db.classes.keys(): | |
| 35 type = db.classes[name] | |
| 36 attributes = type.getprops() | |
| 37 for a in attributes.keys(): | |
| 38 attribute = attributes[a] | |
| 39 if isinstance(attribute, roundup.hyperdb.Link): | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
40 print('node%d -> node%d [label=%s]'%(types.index(name), |
| 1166 | 41 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
42 a)) |
| 1166 | 43 elif isinstance(attribute, roundup.hyperdb.Multilink): |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
44 print('node%d -> node%d [taillabel="*" label=%s]'%(types.index(name), |
| 1166 | 45 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
46 a)) |
| 1166 | 47 # all done |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
48 print('}') |
