tor-browser

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

update_predefined.py (1094B)


      1 #!/usr/bin/env python
      2 
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      6 
      7 from os.path import join, dirname
      8 import re
      9 from urllib.request import urlopen
     10 
     11 
     12 def main(filename):
     13    names = [
     14        re.search('>([^>]+)(</dfn>|<a class="self-link")', line.decode()).group(1)
     15        for line in urlopen("https://drafts.csswg.org/css-counter-styles/")
     16        if b'data-dfn-for="<counter-style-name>"' in line
     17        or b'data-dfn-for="<counter-style>"' in line
     18    ]
     19    with open(filename, "w") as f:
     20        f.write(
     21            """\
     22 /* This Source Code Form is subject to the terms of the Mozilla Public
     23 * License, v. 2.0. If a copy of the MPL was not distributed with this
     24 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
     25 
     26 predefined! {
     27 """
     28        )
     29        for name in names:
     30            f.write('    "%s",\n' % name)
     31        f.write("}\n")
     32 
     33 
     34 if __name__ == "__main__":
     35    main(join(dirname(__file__), "predefined.rs"))