And warn about unsupported versions.
... | ... |
@@ -1146,6 +1146,8 @@ class DotParser(Parser): |
1146 | 1146 |
|
1147 | 1147 |
class XDotParser(DotParser): |
1148 | 1148 |
|
1149 |
+ XDOTVERSION = '1.6' |
|
1150 |
+ |
|
1149 | 1151 |
def __init__(self, xdotcode): |
1150 | 1152 |
lexer = DotLexer(buf = xdotcode) |
1151 | 1153 |
DotParser.__init__(self, lexer) |
... | ... |
@@ -1158,26 +1160,34 @@ class XDotParser(DotParser): |
1158 | 1160 |
|
1159 | 1161 |
def handle_graph(self, attrs): |
1160 | 1162 |
if self.top_graph: |
1163 |
+ # Check xdot version |
|
1161 | 1164 |
try: |
1162 |
- bb = attrs['bb'] |
|
1165 |
+ xdotversion = attrs['xdotversion'] |
|
1163 | 1166 |
except KeyError: |
1164 |
- return |
|
1167 |
+ pass |
|
1168 |
+ else: |
|
1169 |
+ if float(xdotversion) > float(self.XDOTVERSION): |
|
1170 |
+ sys.stderr.write('warning: xdot version %s, but supported is %s\n' % (xdotversion, self.XDOTVERSION)) |
|
1165 | 1171 |
|
1166 |
- if not bb: |
|
1172 |
+ # Parse bounding box |
|
1173 |
+ try: |
|
1174 |
+ bb = attrs['bb'] |
|
1175 |
+ except KeyError: |
|
1167 | 1176 |
return |
1168 | 1177 |
|
1169 |
- xmin, ymin, xmax, ymax = map(float, bb.split(",")) |
|
1178 |
+ if bb: |
|
1179 |
+ xmin, ymin, xmax, ymax = map(float, bb.split(",")) |
|
1170 | 1180 |
|
1171 |
- self.xoffset = -xmin |
|
1172 |
- self.yoffset = -ymax |
|
1173 |
- self.xscale = 1.0 |
|
1174 |
- self.yscale = -1.0 |
|
1175 |
- # FIXME: scale from points to pixels |
|
1181 |
+ self.xoffset = -xmin |
|
1182 |
+ self.yoffset = -ymax |
|
1183 |
+ self.xscale = 1.0 |
|
1184 |
+ self.yscale = -1.0 |
|
1185 |
+ # FIXME: scale from points to pixels |
|
1176 | 1186 |
|
1177 |
- self.width = max(xmax - xmin, 1) |
|
1178 |
- self.height = max(ymax - ymin, 1) |
|
1187 |
+ self.width = max(xmax - xmin, 1) |
|
1188 |
+ self.height = max(ymax - ymin, 1) |
|
1179 | 1189 |
|
1180 |
- self.top_graph = False |
|
1190 |
+ self.top_graph = False |
|
1181 | 1191 |
|
1182 | 1192 |
for attr in ("_draw_", "_ldraw_", "_hdraw_", "_tdraw_", "_hldraw_", "_tldraw_"): |
1183 | 1193 |
if attr in attrs: |