svgattrs.py 570 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/python2.3
  2. """Expose Inkscape SVG attributes.
  3. Read an Inkscape SVG from stdin.
  4. Output attributes to the "<svg>" element to stdout.
  5. """
  6. import sys
  7. import xml.sax
  8. class InkscapeSvgHandler(xml.sax.ContentHandler):
  9. """Print attributes to svg element."""
  10. def startElement(self, name, attrs):
  11. if name == "svg":
  12. for (k,v) in attrs.items():
  13. print k + " " + v
  14. if __name__ == "__main__":
  15. parser = xml.sax.make_parser()
  16. parser.setContentHandler(InkscapeSvgHandler())
  17. parser.parse(sys.stdin)
  18. sys.exit(0)