-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_illustration.py
70 lines (65 loc) · 2.71 KB
/
graph_illustration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from datastructs import *
from functools import reduce
def getNodeShape(node: Node):
if isinstance(node, SelectNode):
return 'diamond'
if isinstance(node, TargetNode):
return 'box'
if isinstance(node, ConcatNode):
return 'doubleoctagon'
if isinstance(node, CustomCommandNode):
return 'parallelogram'
if isinstance(node, TestNode):
return 'component'
if isinstance(node, RefNode):
return 'cds'
if isinstance(node, OptionNode):
return 'larrow'
return 'ellipse'
def getEdgeLabel(firstNode: Node, secondNode: Node):
if isinstance(firstNode, TargetNode):
if firstNode.definitions == secondNode:
return "Definitions"
if firstNode.interfaceDefinitions == secondNode:
return "Interface_definitions"
if firstNode.linkLibraries == secondNode:
return "Libraries"
if firstNode.sources == secondNode:
return "Sources"
if firstNode.interfaceSources == secondNode:
return "Interface_sources"
if firstNode.compileFeatures == secondNode:
return "Compile_features"
if firstNode.interfaceCompileFeatures == secondNode:
return "Interface_compile_features"
if firstNode.compileOptions == secondNode:
return "Compile_options"
if firstNode.interfaceCompileOptions == secondNode:
return "Interface_compile_options"
if firstNode.includeDirectories == secondNode:
return "INCLUDE_DIRECTORIES"
if firstNode.interfaceIncludeDirectories == secondNode:
return "INTERFACE_INCLUDE_DIRECTORIES"
if firstNode.interfaceSystemIncludeDirectories == secondNode:
return "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"
if isinstance(firstNode, SelectNode):
if firstNode.trueNode == secondNode:
return "TRUE"
elif firstNode.falseNode == secondNode:
return "FALSE"
elif firstNode.args == secondNode:
return "CONDITION"
if isinstance(firstNode, DefinitionNode):
if firstNode.inherits and reduce(lambda x, y: x or y == secondNode, firstNode.inherits, False):
return "INHERITS"
if isinstance(firstNode, CustomCommandNode):
if firstNode.commands and reduce(lambda x, y: x or y == secondNode, firstNode.commands, False):
return "COMMANDS"
elif firstNode.depends and reduce(lambda x, y: x or y == secondNode, firstNode.depends, False):
return "DEPENDS"
if isinstance(firstNode, OptionNode):
if firstNode.depends == secondNode:
return 'DEPENDS'
if isinstance(firstNode, RefNode):
return firstNode.relatedProperty
return None