7 from copy
import deepcopy
9 graphviz_command =
"dot" 17 filename = directory + name +
".xml" 18 with open(filename,
'r') as i: 23 contents =
read(directory, name)
24 scenes = contents.split(
"<scene ")
27 bitcomp += directory + name +
"; " 32 if not scene.find(
"ocm") == -1:
33 scenename = scene.split(
"name=\"")[1].split(
"\"")[0]
34 nodes = scene.split(
"<")
38 values = node.split(
" ")
39 if values[0] ==
"object":
41 rootlist.append([deepcopy(nodelist), root.name])
46 root.name = values[1].split(
"\"")[1]
50 if values[0] ==
"child":
52 child.name = values[1].split(
"\"")[1]
53 child.parent = [currentroot]
54 child.reference = (len(values) > 2)
56 nodelist.append(child)
57 if values[0] ==
"/child>":
58 currentroot = currentroot.parent[0]
59 rootlist.append([deepcopy(nodelist), root.name])
65 dot =
"digraph " + name +
"_" + rootname +
" {\n" 69 dot += o[1] +
"[label=" + o[1] +
"]\n" 74 if not o.name ==
"NULL" and not o.parent[0].name ==
"NULL":
75 dot += o.parent[0].name +
" -> " + o.name
77 dot +=
"[style=dashed]" 84 dotname = scenename +
"_" + rootname
85 outname = directory + name +
"_" + dotname +
".dot" 86 with open(outname,
'w')
as f:
89 dots.append(scenename +
"_" + rootname)
95 subprocess.call([graphviz_command,
"-Tpdf", directory + name +
"_" + graph +
".dot",
"-o", directory + name +
"_" + graph +
".pdf"])
102 directory =
"../data/" 103 name =
"advertisement" def xmltodot(directory, name)
def xmltopdf(directory, name)
def read(directory, name)
def dottopdf(directory, name, graphs)