def svg_to_path(file_obj, file_type=None):
    """
    Load an SVG file into a Path2D object.

    Parameters
    -----------
    file_obj : open file object
      Contains SVG data
    file_type: None
      Not used

    Returns
    -----------
    loaded : dict
      With kwargs for Path2D constructor
    """

    def element_transform(e, max_depth=100):
        """
        Find a transformation matrix for an XML element.
        """
        matrices = []
        current = e
        for i in range(max_depth):
            if 'transform' in current.attrib:
                mat = transform_to_matrices(current.attrib['transform'])
                matrices.extend(mat)
                # cached[current] = mat
            current = current.getparent()
            if current is None:
                break

        if len(matrices) == 0:
            return np.eye(3)
        elif len(matrices) == 1:
            return matrices[0]
        else:
            return util.multi_dot(matrices[::-1])

    # first parse the XML
    xml = etree.fromstring(file_obj.read())

    # store paths and transforms as
    # (path string, 3x3 matrix)
    paths = []

    # store every path element
    for element in xml.iter('{*}path'):
        paths.append((element.attrib['d'],
                      element_transform(element)))

    return _svg_path_convert(paths)
def svg_to_path ( file_obj , file_type = None ) : def element_transform ( e , max_depth = 100 ) : matrices = [ ] current = e for i in range ( max_depth ) : if 'transform' in current . attrib : mat = transform_to_matrices ( current . attrib [ 'transform' ] ) matrices . extend ( mat ) current = current . getparent ( ) if current is None : break if len ( matrices ) == 0 : return np . eye ( 3 ) elif len ( matrices ) == 1 : return matrices [ 0 ] else : return util . multi_dot ( matrices [ : : - 1 ] ) xml = etree . fromstring ( file_obj . read ( ) ) paths = [ ] for element in xml . iter ( '{*}path' ) : paths . append ( ( element . attrib [ 'd' ] , element_transform ( element ) ) ) return _svg_path_convert ( paths )
Load an SVG file into a Path2D object.

    Parameters
    -----------
    file_obj : open file object
      Contains SVG data
    file_type: None
      Not used

    Returns
    -----------
    loaded : dict
      With kwargs for Path2D constructor