blob: a7205e3f00369f58a2718de94ecf09c14bb6bbbb (
plain)
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
|
#Author: Shu Shi
#emaiL: shushi@research.att.com
LEVEL_NODE_NAME = 1
LEVEL_NODE_DETAILS = 2
LEVEL_NODE_EVERYTHING = 3
def _print_template(template, level=LEVEL_NODE_DETAILS):
print_str = ''
if template is None:
return print_str
print_str += 'Nodes:'+ '\n'
for node in iter(template.node_dict.values()):
print_str += _print_node(node, level)
return print_str
def _print_node(node, level):
print_str = ''
if node is None:
return
print_str += ' '+ node.name + '\n'
print_str += ' type: '+ node.type+ '\n'
if level == LEVEL_NODE_DETAILS:
if len(node.properties) > 0:
print_str += ' properties:' + '\n'
for prop in iter(node.properties.values()):
if prop.filled:
print_str += ' '+ prop.name+ ': '+ str(prop.value._get_value()[0])+ '\n'
else:
print_str += ' '+ prop.name+ ': null'+ '\n'
if len(node.requirements)> 0:
print_str += ' requirements:'+ '\n'
for req in node.requirements:
if req.filled:
print_str += ' '+ req.name+ ': '+ req.value.name+ '\n'
else:
print_str += ' '+ req.name+ ': null'+ '\n'
print_str += ''+ '\n'
return print_str
def _print_node_types(db):
print_str = 'Available node types: '+ '\n'
for name in db.NODE_TYPES.keys():
print_str += name, '\n'
return print_str
def _print_templates(db):
print_str = 'Available templates: '+ '\n'
for name in db.TEMPLATES.keys():
print_str += name, '\n'
return print_str
def _print_node_type(node_type):
print_str = 'Node Type Definition: '+ node_type.name+ '\n'
print_str += node_type.raw_content+ '\n'
return print_str
|