Ejemplo n.º 1
0
def parse_svg_string(xml_string, image_props, system_language="en"):
    """Parses the SVG document in the given string, using the image_props
    to build an image.

    """

    ET.register_namespace("svg", "{http://www.w3.org/2000/svg}")
    root = ET.fromstring(xml_string)
    if root.tag == ns_svg("svg"):
        parse_svg_root_node(root, image_props, system_language)
    else:
        raise ifaint.LoadError("Root element was not <svg>.")
Ejemplo n.º 2
0
def parse_doc(path, image_props, system_language="en"):
    """Parses the SVG document at the given file path, using the
    image_props to build an image.

    """
    ET.register_namespace("svg", "{http://www.w3.org/2000/svg}")
    tree = ET.parse(path)
    root = tree.getroot()
    if root.tag == ns_svg("svg"):
        parse_svg_root_node(root, image_props, system_language)
    else:
        raise ifaint.LoadError("Root element was not <svg>.")