Mercurial > p > roundup > code
annotate scripts/schema_diagram.py @ 7695:2be7a8f66ea7
fix: windows install using pip mislocates share directory
The setup code that tries to make the share install path absolute
prependeds something like:
c:\program files\python_venv
to the paths. The equivalent on linux is recognized as an absolute
path. On windows this is treated oddly. This resulted in
the share files being placed in:
c:\program files\python_venv\Lib\site-packages\program files\python_venv\share
Roundup was unable to find the files there. On windows (where the
platform starts with 'win') don't make the path absolute. This puts
share in:
c:\program files\python_venv\Lib\share
and Roundup finds them.
The translations and templates are found by the roundup-server.
The docs are also installed under the share directory. The man pages
are not installed as windows doesn't have groff to format the source
documents.
This is the second fix from issues getting Roundup running on windows
discussed on mailing list by Simon Eigeldinger.
Thread starts with:
https://sourceforge.net/p/roundup/mailman/message/41557096/
subject: Installing Roundup on Windows 2023-10-05.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 05 Nov 2023 23:01:29 -0500 |
| parents | 23b8e6067f7c |
| children | 9c3ec0a5c7fc |
| 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 # | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
13 from __future__ import print_function |
| 1166 | 14 import sys |
| 15 import roundup.instance | |
| 16 | |
| 17 # open the instance | |
| 18 instance = roundup.instance.open(sys.argv[1]) | |
| 19 db = instance.open() | |
| 20 | |
| 21 # diagram preamble | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
22 print('digraph schema {') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
23 print('size="8,6"') |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
24 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
|
25 print('edge [taillabel="1" headlabel="1" dir=back arrowtail=ediamond]') |
| 1166 | 26 |
| 27 # get all the classes | |
|
5395
23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5376
diff
changeset
|
28 types = list(db.classes.keys()) |
| 1166 | 29 |
| 30 # one record node per class | |
| 31 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
|
32 print('node%d [label=\"{%s|}"]'%(i, types[i])) |
| 1166 | 33 |
| 34 # now draw in the relations | |
| 35 for name in db.classes.keys(): | |
| 36 type = db.classes[name] | |
| 37 attributes = type.getprops() | |
| 38 for a in attributes.keys(): | |
| 39 attribute = attributes[a] | |
| 40 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
|
41 print('node%d -> node%d [label=%s]'%(types.index(name), |
| 1166 | 42 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
43 a)) |
| 1166 | 44 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
|
45 print('node%d -> node%d [taillabel="*" label=%s]'%(types.index(name), |
| 1166 | 46 types.index(attribute.classname), |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
47 a)) |
| 1166 | 48 # all done |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
1166
diff
changeset
|
49 print('}') |
