Take into account of inheritance relations in schema2dot (closes #88599).

authorDamien Garaud <damien.garaud@logilab.fr>
changeset045519650511
branchdefault
phasepublic
hiddenno
parent revision#7227371af9a9 fix regression introduced in 666:4d25fa7c13d9 and remove ambiguity on format_constraint on the way
child revision#cd13de2d6d4e backport stable
files modified by this revision
ChangeLog
schema2dot.py
# HG changeset patch
# User Damien Garaud <damien.garaud@logilab.fr>
# Date 1328861702 -3600
# Fri Feb 10 09:15:02 2012 +0100
# Node ID 045519650511290528bdf4d373a4a797846a2ad6
# Parent 7227371af9a99a2126040aa8a5ee7887998a471b
Take into account of inheritance relations in schema2dot (closes #88599).

diff --git a/ChangeLog b/ChangeLog
@@ -1,8 +1,15 @@
1  ChangeLog for yams
2  ------------------
3 
4 +	--
5 +    * generic metadata attributes handling (#83813)
6 +    * fix debian packaging to be installable with python = 2.7 (#83759)
7 +    * take into account of inheritance relations in schema2dot (#88599)
8 +    * RichString is now a function
9 +    * final types are now explicitly created to please pylint
10 +
11  2011-11-03  --  0.34.0
12      * fixed yams-view script
13 
14      * sqldropscham2sql now takes a dbhelper as argument to handle db specificities
15 
diff --git a/schema2dot.py b/schema2dot.py
@@ -122,10 +122,15 @@
16      def nodes(self):
17          for eschema in self._eindex.values():
18              yield eschema.type, eschema
19 
20      def edges(self):
21 +        # Entities with inheritance relations.
22 +        for eschema in self._eindex.values():
23 +            if eschema.specializes():
24 +                yield str(eschema), str(eschema.specializes()), None
25 +        # Subject/object relations.
26          for rschema in self.schema.relations():
27              if not self.should_display_schema(rschema):
28                  continue
29              for setype, tetype in rschema.rdefs:
30                  if not (setype in self._eindex and tetype in self._eindex):
@@ -155,10 +160,18 @@
31              for teschema in rschema.subjects(eschema.type):
32                  nodes.add((teschema.type, teschema))
33                  if not self.display_rel(rschema, teschema.type, eschema.type):
34                      continue
35                  edges.add((teschema.type, eschema.type, rschema))
36 +        # Inheritance relations.
37 +        if eschema.specializes():
38 +            nodes.add((eschema.specializes().type, eschema.specializes()))
39 +            edges.add((eschema.type, eschema.specializes().type, None))
40 +        if eschema.specialized_by():
41 +            for pschema in eschema.specialized_by():
42 +                nodes.add((pschema.type, pschema))
43 +                edges.add((pschema.type, eschema.type, None))
44          self._nodes = nodes
45          self._edges = edges
46 
47 
48  class OneHopRSchemaVisitor(SchemaVisitor):