Changeset 82:6fe4b0e529b9 for relatorio/templates/opendocument.py
- Timestamp:
- 11/19/08 09:07:39 (21 months ago)
- Branch:
- default
- Files:
-
- 1 modified
-
relatorio/templates/opendocument.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
relatorio/templates/opendocument.py
r74 r82 50 50 EtreeElement = lxml.etree.Element 51 51 52 def guess_type(val): 53 if isinstance(val, (str, unicode)): 54 return 'string' 55 elif isinstance(val, (int, float)): 56 return 'float' 52 57 53 58 class OOTemplateError(genshi.template.base.TemplateSyntaxError): … … 260 265 if parent is None or parent.tag != table_cell_tag: 261 266 continue 262 if parent.attrib.get(office_valuetype, 'string') != 'string': 263 # The grand-parent tag is a table cell we set the 264 # office:value attribute of this cell 265 dico = "{'%s': %s}" % (office_name, expr) 266 parent.attrib[attrib_name] = dico 267 parent.attrib.pop(office_name, None) 267 268 # The grand-parent tag is a table cell we should set the 269 # correct value and type for this cell. 270 dico = "{'%s': %s, '%s': guess_type(%s)}" 271 parent.attrib[attrib_name] = dico % (office_name, expr, 272 office_valuetype, 273 expr) 274 parent.attrib.pop(office_valuetype, None) 275 parent.attrib.pop(office_name, None) 268 276 269 277 def _handle_images(self, tree): … … 293 301 serializer = OOSerializer(self.filepath) 294 302 kwargs['make_href'] = ImageHref(serializer.outzip, kwargs) 303 kwargs['guess_type'] = guess_type 295 304 generate_all = super(Template, self).generate(*args, **kwargs) 296 305
