def convert_svg(svgstr, size, filepath, target):
<EOL>if target == "<STR_LIT>":<EOL><INDENT>img = cairo.PDFSurface(filepath, size, size)<EOL><DEDENT>elif target == "<STR_LIT>":<EOL><INDENT>img = cairo.ImageSurface(cairo.FORMAT_ARGB32, size, size)<EOL><DEDENT>else:<EOL><INDENT>system.exit("<STR_LIT>")<EOL><DEDENT>ctx = cairo.Context(img)<EOL>handler= rsvg.Handle(None, svgstr)<EOL>iw,ih, fw,fh =  handler.get_dimension_data()<EOL>ctx.translate(<NUM_LIT:0>,<NUM_LIT:0>)<EOL>ctx.scale(size/fw, size/fh) <EOL>handler.render_cairo(ctx)<EOL>if target == "<STR_LIT>":<EOL><INDENT>img.write_to_png(filepath)<EOL><DEDENT>
convert to PDF or PNG