def parseString(rml, localcontext=None, fout=None, images=None, path='.', title=None): node = etree.XML(rml) r = _rml_doc(node, localcontext, images, path, title=title) #try to override some font mappings try: from customfonts import SetCustomFonts SetCustomFonts(r) except Exception: pass if fout: fp = file(fout, 'wb') r.render(fp) fp.close() return fout else: fp = StringIO() r.render(fp) return fp.getvalue()
def parseNode(rml, localcontext=None, fout=None, images=None, path='.', title=None): node = etree.XML(rml) if localcontext is None: localcontext = {} if images is None: images = {} r = _rml_doc(node, localcontext, images, path, title=title) #try to override some font mappings try: from customfonts import SetCustomFonts SetCustomFonts(r) except ImportError: # means there is no custom fonts mapping in this system. pass except Exception: logging.getLogger('report').warning('Cannot set font mapping', exc_info=True) pass fp = StringIO() r.render(fp) return fp.getvalue()
def parseNode(rml, localcontext={}, fout=None, images={}, path='.', title=None): node = etree.XML(rml) r = _rml_doc(node, localcontext, images, path, title=title) #try to override some font mappings try: from customfonts import SetCustomFonts SetCustomFonts(r) except Exception: pass fp = cStringIO.StringIO() r.render(fp) return fp.getvalue()