def get_attributes(self, element): attributes = pinky.parse_style(element.getAttribute('style')) attribute_nodes = element.attributes for i in xrange(attribute_nodes.length): attribute_node = attribute_nodes.item(i) attributes[attribute_node.localName] = attribute_node.nodeValue for child in element.childNodes: if (child.nodeType == child.ELEMENT_NODE and child.namespaceURI == pinky.SVG_NAMESPACE and child.localName == 'desc'): if child.firstChild.nodeType == child.TEXT_NODE: desc_attributes = pinky.parse_style(child.firstChild.nodeValue) attributes.update(desc_attributes) break return attributes
def load_shapes(self, element, matrix): attributes = dict(element.attributes) attributes.update(pinky.parse_style(attributes.pop('style', ''))) # attributes.update(pinky.parse_style(attributes.pop('desc', ''))) matrix = matrix * element.matrix fill = pinky.Color.parse(attributes.get('fill', 'none')) stroke = pinky.Color.parse(attributes.get('stroke', 'none')) if element.shape is not None: self.add_shape(element.shape, matrix, fill, stroke) for child in element.children: self.load_shapes(child, matrix)