]>
git.proxmox.com Git - mirror_ovs.git/blob - ovsdb/dot2pic
3 # Copyright (c) 2009, 2010, 2011, 2013, 2017 Nicira, Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 def dot2pic(src
, dst
):
29 if command
== 'graph':
30 scale
= float(words
[1])
31 elif command
== 'node':
35 width
= float(words
[4])
36 height
= float(words
[5])
37 label
, style
, shape
, color
, fillcolor
= words
[6:11]
42 dst
.write("linethick = %f;\n" % (0.5 if style
== 'bold' else 1.0))
43 dst
.write('box at %f,%f wid %f height %f "%s"\n'
44 % (x
, y
, width
, height
, name
))
49 dst
.write("box at %f,%f wid %f height %f\n"
50 % (x
, y
, width
, height
))
51 elif command
== 'edge':
56 # Extract x,y coordinates.
60 x
= float(words
[0]) * scale
61 y
= float(words
[1]) * scale
65 # Extract style and color from end of words.
66 style
, color
= words
[-2:]
69 # If there's anything left, that's the label.
71 xl
= float(words
[-2]) * scale
72 yl
= float(words
[-1]) * scale
73 label
= ' '.join(words
[:-2])
74 if label
.startswith('"') and label
.endswith('"'):
79 dst
.write("linethick = %f;\n"
80 % (0.5 if style
== 'dotted' else 1.0))
81 dst
.write("spline -> from %f,%f" % xy
[0])
83 dst
.write(" to %f,%f" % (x
, y
))
87 dst
.write('"%s" at %f,%f\n' % (label
, xl
, yl
))
88 elif command
== 'stop':
91 sys
.stderr
.write("%s\n" % command
)
95 options
, args
= getopt
.gnu_getopt(sys
.argv
[1:], 'f:', [])
98 for key
, value
in options
:
100 font_scale
= int(value
)
105 print(".ps %+d" % -font_scale
)
108 print("linethick = 1;")
111 dot2pic(open(arg
), sys
.stdout
)
113 dot2pic(sys
.stdin
, sys
.stdout
)
115 print(".ps %+d" % font_scale
)