Skip to content

Commit 495681f

Browse files
committed
Merge commit '1f859dcc3368828268982381246a55f9d0b0b28d' into dev
2 parents e63e16d + 1f859dc commit 495681f

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/prov/dot.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
from __future__ import (absolute_import, division, print_function,
1515
unicode_literals)
1616

17-
try:
18-
from html import escape
19-
except ImportError:
20-
from cgi import escape
2117
from datetime import datetime
22-
import pydot
2318
import six
2419

20+
from prov.graph import INFERRED_ELEMENT_CLASS
2521
from prov.model import (
2622
ProvEntity, ProvActivity, ProvAgent, ProvBundle,
2723
PROV_ACTIVITY, PROV_AGENT, PROV_ALTERNATE, PROV_ASSOCIATION,
@@ -31,7 +27,12 @@
3127
PROV_SPECIALIZATION, PROV_START, PROV_USAGE, Identifier,
3228
PROV_ATTRIBUTE_QNAMES, sorted_attributes, ProvException
3329
)
34-
from prov.graph import INFERRED_ELEMENT_CLASS
30+
import pydot
31+
32+
try:
33+
from html import escape
34+
except ImportError:
35+
from cgi import escape
3536

3637
__author__ = 'Trung Dong Huynh'
3738
__email__ = 'trungdong@donggiang.com'
@@ -62,6 +63,11 @@
6263
}
6364
}
6465
DOT_PROV_STYLE = {
66+
# Generic node
67+
0: {
68+
'shape': 'oval', 'style': 'filled',
69+
'fillcolor': 'lightgray', 'color': 'dimgray'
70+
},
6571
# Elements
6672
PROV_ENTITY: {
6773
'shape': 'oval', 'style': 'filled',
@@ -274,13 +280,13 @@ def _add_node(record):
274280
_attach_attribute_annotation(node, rec)
275281
return node
276282

277-
def _add_generic_node(qname, prov_type):
283+
def _add_generic_node(qname, prov_type=None):
278284
count[0] += 1
279285
node_id = 'n%d' % count[0]
280286
node_label = '"%s"' % six.text_type(qname)
281287

282288
uri = qname.uri
283-
style = GENERIC_NODE_STYLE[prov_type]
289+
style = GENERIC_NODE_STYLE[prov_type] if prov_type else DOT_PROV_STYLE[0]
284290
node = pydot.Node(
285291
node_id, label=node_label, URL='"%s"' % uri, **style
286292
)
@@ -297,7 +303,7 @@ def _get_bnode():
297303
dot.add_node(bnode)
298304
return bnode
299305

300-
def _get_node(qname, prov_type):
306+
def _get_node(qname, prov_type=None):
301307
if qname is None:
302308
return _get_bnode()
303309
uri = qname.uri

0 commit comments

Comments
 (0)