You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # DISTRHO Plugin Framework (DPF)
  4. # Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any purpose with
  7. # or without fee is hereby granted, provided that the above copyright notice and this
  8. # permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  11. # TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  12. # NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. # DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  14. # IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  15. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. import os
  17. import sys
  18. import xml.etree.ElementTree as ET
  19. # -----------------------------------------------------
  20. def svg2stub(filename_in, filename_out):
  21. node = ET.parse(filename_in).getroot()
  22. with open(filename_out, 'w') as fh:
  23. fh.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n')
  24. fh.write('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"')
  25. for key, value in node.items():
  26. if '{' in key:
  27. continue
  28. fh.write(' %s="%s"' % (key, value))
  29. fh.write('></svg>')
  30. # -----------------------------------------------------
  31. if __name__ == '__main__':
  32. if len(sys.argv) != 3:
  33. print("Usage: %s <in-filename> <out-filename>" % sys.argv[0])
  34. quit()
  35. filename_in = sys.argv[1]
  36. filename_out = sys.argv[2]
  37. if not os.path.exists(filename_in):
  38. print("File '%s' does not exist" % filename_in)
  39. quit()
  40. # dump code now
  41. svg2stub(filename_in, filename_out)