def __html_repr__(self, kit): tags = kit.tags if tags is None: tags = xml_tags stdin, stdout, stderr = popen3(['dot','-Tsvg']) stdin.write(self) stdin.close() error = stderr.read().strip() if error: print error stderr.close() svg = stdout.read() result_xml = Tag.parseString(svg) height = result_xml['height'] width = result_xml['width'] stdout = StringIO(svg) return tags.object( type = 'image/svg+xml', data = host( stdout, content_type = 'image/svg+xml' ), onload = 'messageBuffer.autoScroll()', style = 'width: %s; height: %s' % (width, height), )
def parse(Self, file): xml = Tag.parse(file) return Self( width = xml['width'], height = xml['height'], groups = list( element for element in xml.tags if element.name == 'g' ), defs = dict( (element['id'], element) for element in xml[Name('defs')].tags ), )
def stringReceived(self, string): self.tagsReceived(Tag.parseString(string))