123456789101112131415161718192021222324252627282930313233343536373839 |
- #!/usr/bin/env python3
- import os
- import fileinput
- import re
- import sys
- file_path_html = 'glife.html'
- deprecatedTag = "deprecated"
- data = ''
- with open(file_path_html, 'r') as file:
- data = file.read()
- dataLengthInitial = len(data)
- dataWithoutDeprecated = data
- i = 0
- regex = r"""<tw-passagedata pid="(\d+)" name="([\s\w]+)" tags="(.*?)" (?:position="\d+,\d+" )?(?:size="\d+,\d+")?>(.*?)</tw-passagedata>"""
- for match in re.finditer(regex,data,re.S):
- tags = match.group(3).split()
- if(deprecatedTag in tags):
- dataWithoutDeprecated = dataWithoutDeprecated.replace(match.group(0),'')
- print('Removed:'+match.group(2))
- with open(file_path_html, 'w') as file:
- file.write(dataWithoutDeprecated)
- dataLengthEnd = len(dataWithoutDeprecated)
- print(f'POSTCOMPILE DONE, REMAINING SIZE {round(dataLengthEnd/dataLengthInitial*100,1)}%')
|