tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

appearance-build-webkit-reftests.py (956B)


      1 #!/usr/bin/env python3
      2 import os
      3 import re
      4 
      5 re_testname = re.compile(r"^appearance-.+\d\d\d\.html$")
      6 re_link_match = re.compile(r'<link rel="(mis)?match"')
      7 
      8 files = {}
      9 
     10 parentdir = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir))
     11 assert parentdir.endswith('/css-ui')
     12 
     13 for filename in os.listdir(parentdir):
     14    path = os.path.join(parentdir, filename)
     15    if os.path.isfile(path) and re_testname.search(filename) and not filename in files:
     16        with open(path, "r") as file:
     17            files[filename] = file.read()
     18 
     19 warning = """<!-- DO NOT EDIT THIS FILE.
     20 Edit the appearance-* file instead and then run:
     21    ./tools/appearance-build-webkit-reftests.py
     22 -->
     23 """
     24 
     25 for filename, text in files.items():
     26    if re_link_match.search(text):
     27        with open(os.path.join(parentdir, filename.replace("appearance-", "webkit-appearance-")), "w") as outfile:
     28            outfile.write(warning + text.replace("appearance:", "-webkit-appearance:"))