def POST_upload_svg (): # called by SVG editor when submitting a SVG for upload print "file = ", request.files.get("file") upload = request.files.get("file") tree = ET.parse(upload.file) svg = tree.getroot() result = process_svg(svg) # read instructions from input if it exists instr_string = None upload.file.seek(0) for line in upload.file: if has_interactive_script(line): instr_string = "" elif line.strip() == "-->": break elif instr_string is not None: instr_string += line if instr_string is None: instr_string = "" result["instr"] = instr_string result["fonts"] = compile.get_fonts(svg) return result
def POST_upload_svg (): # called by SVG editor when submitting a SVG for upload print "file = ", request.files.get("file") ox = request.forms.get("ox") oy = request.forms.get("oy") ow = request.forms.get("ow") oh = request.forms.get("oh") upload = request.files.get("file") tree = ET.parse(upload.file) svg = tree.getroot() svg = compile.fix_fonts(svg,"sans-serif") svg.attrib["x"] = ox svg.attrib["y"] = oy svg.attrib["width"] = ow svg.attrib["height"] = oh result = process_svg(svg) # read instructions from input if it exists instr_string = None upload.file.seek(0) for line in upload.file: if has_interactive_script(line): instr_string = "" elif line.strip() == "-->": break elif instr_string is not None: instr_string += line if instr_string is None: instr_string = "" result["instr"] = instr_string result["fonts"] = compile.get_fonts(svg) return result