comparison pyink/html5css3.py @ 1364:aa7cbf2cbf34 s

Fix bug of SVG been fault for showing
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 18 Feb 2011 14:02:53 +0800
parents a05ea7fa43ec
children dc6591b4079d
comparison
equal deleted inserted replaced
1363:a05ea7fa43ec 1364:aa7cbf2cbf34
118 indent = ' ' * lvl 118 indent = ' ' * lvl
119 print >> out, '%s%s' % (indent, txt) 119 print >> out, '%s%s' % (indent, txt)
120 pass 120 pass
121 121
122 def _print_node_open(node, lvl, out): 122 def _print_node_open(node, lvl, out):
123 node_name = node.name()
124 if node_name.startswith('svg:'):
125 node_name = node_name[4:]
126 pass
127
123 attrs = [] 128 attrs = []
124 for attrname in node.allAttributes(): 129 for attrname in node.allAttributes():
125 attrvalue = node.getAttribute(attrname) 130 attrvalue = node.getAttribute(attrname)
126 attr = '%s="%s"' % (attrname, attrvalue) 131 attr = '%s="%s"' % (attrname, attrvalue)
127 attrs.append(attr) 132 attrs.append(attr)
128 pass 133 pass
129 134
130 if attrs: 135 if attrs:
131 attrs_str = ' '.join(attrs) 136 attrs_str = ' '.join(attrs)
132 line = '<%s %s>' % (node.name(), attrs_str) 137 line = '<%s %s>' % (node_name, attrs_str)
133 else: 138 else:
134 line = '<%s>' % (node.name()) 139 line = '<%s>' % (node_name)
135 pass 140 pass
136 _print_level(line, lvl, out) 141 _print_level(line, lvl, out)
137 pass 142 pass
138 143
139 def _print_node_close(node, lvl, out): 144 def _print_node_close(node, lvl, out):
140 line = '</%s>' % (node.name()) 145 node_name = node.name()
146 if node_name.startswith('svg:'):
147 node_name = node_name[4:]
148 pass
149
150 line = '</%s>' % (node_name)
141 _print_level(line, lvl, out) 151 _print_level(line, lvl, out)
142 pass 152 pass
143 153
144 def _print_node_single(node, lvl, out): 154 def _print_node_single(node, lvl, out):
155 node_name = node.name()
156 if node_name.startswith('svg:'):
157 node_name = node_name[4:]
158 pass
159
145 attrs = [] 160 attrs = []
146 for attrname in node.allAttributes(): 161 for attrname in node.allAttributes():
147 attrvalue = node.getAttribute(attrname) 162 attrvalue = node.getAttribute(attrname)
148 attr = '%s="%s"' % (attrname, attrvalue) 163 attr = '%s="%s"' % (attrname, attrvalue)
149 attrs.append(attr) 164 attrs.append(attr)
150 pass 165 pass
151 166
152 if attrs: 167 if attrs:
153 attrs_str = ' '.join(attrs) 168 attrs_str = ' '.join(attrs)
154 line = '<%s %s/>' % (node.name(), attrs_str) 169 line = '<%s %s/>' % (node_name, attrs_str)
155 else: 170 else:
156 line = '<%s/>' % (node.name()) 171 line = '<%s/>' % (node_name)
157 pass 172 pass
158 _print_level(line, lvl, out) 173 _print_level(line, lvl, out)
159 pass 174 pass
160 175
161 def _print_node_content(node, lvl, out): 176 def _print_node_content(node, lvl, out):
267 import sys 282 import sys
268 parser = dom_parser() 283 parser = dom_parser()
269 self._parser = parser 284 self._parser = parser
270 parser.start_handle(doc.rdoc) 285 parser.start_handle(doc.rdoc)
271 286
272 print parser._maxframe
273 print doc.rdoc.root().allAttributes()
274 print parser.all_comp_names()
275 print 'save to ' + filename
276
277 self._handle_transition_layers() 287 self._handle_transition_layers()
278 print self._stylesheet.keys() 288
289 out = file(filename, 'w+')
290 print >> out, '''\
291 <html
292 xmlns:dc="http://purl.org/dc/elements/1.1/"
293 xmlns:cc="http://creativecommons.org/ns#"
294 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
295 xmlns:svg="http://www.w3.org/2000/svg"
296 xmlns:xlink="http://www.w3.org/1999/xlink"
297 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
298 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
299 xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd"
300 >
301 <head>
302 <title>Scribboo Test Page</title>
303 <!-- Style for animation transitions -->
304 <style type='text/css'>'''
305
306 for selector, style in self._stylesheet.items():
307 self._write_css(selector, style, out)
308 pass
309
310 print >> out, '''\
311 </style>
312 </head>
313 <body>'''
314
315 root = doc.rdoc.root()
316 _print_subtree(root, 1, out)
317
318 print >> out, '''\
319 </body>
320 </html>'''
321
322 out.close()
279 pass 323 pass
280 324
281 ## \brief Find all animation pairs. 325 ## \brief Find all animation pairs.
282 # 326 #
283 # An animation pair is two nodes, one from start scene group and 327 # An animation pair is two nodes, one from start scene group and