MakeMod.py 658 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. import os
  3. import fileinput
  4. import re
  5. import sys
  6. modTag = "mod"
  7. file_path_html = 'glife.html'
  8. file_path_mod = 'mods/mod.html'
  9. data = ''
  10. modData = ''
  11. with open(file_path_html, 'r') as file:
  12. data = file.read()
  13. i = 0
  14. regex = r"""<tw-passagedata pid="(\d+)" name="([\s\w]+)" tags="(.*?)" (?:position="\d+,\d+" )?(?:size="\d+,\d+")?>(.*?)</tw-passagedata>"""
  15. for match in re.finditer(regex,data,re.S):
  16. tags = match.group(3).split()
  17. if(modTag in tags):
  18. modData += match.group(0)+'\n'
  19. i += 1
  20. if(i % 100 == 0):
  21. print(i)
  22. with open(file_path_mod, 'w') as file:
  23. file.write(modData)
  24. print('Done')