less copy protection, more size visualization
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

25 строки
747 B

  1. import sys
  2. import re
  3. from xml.etree import ElementTree
  4. from pathlib import Path
  5. for path in Path(sys.argv[1]).rglob('*.svg'):
  6. tree = ElementTree.ElementTree()
  7. parsed = tree.parse(path)
  8. if "width" not in parsed.attrib:
  9. print(f"Rewriting {path}")
  10. width, height = parsed.attrib["viewBox"].split(" ")[-2:]
  11. # I'd rather avoid mangling the XML files by parsing them first
  12. # XML is awful and we never should have invented it :(
  13. with open(path, "r", encoding="utf-8") as file:
  14. data = file.read()
  15. data = re.sub('viewBox="0 0', f'width="{width}" height="{height}" viewBox="0 0', data)
  16. with open(path, "w", encoding="utf-8") as file:
  17. file.write(data)