File: generate.py

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (78 lines) | stat: -rwxr-xr-x 2,130 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python

import os
import sys

THIS_NAME = u"generate.py"

# Note: these lists must be kept in sync with the lists in
# Document-createElement-namespace.html, and this script must be run whenever
# the lists are updated.  (We could keep the lists in a shared JSON file, but
# seems like too much effort.)
FILES = (
    (u"empty", u""),
    (u"minimal_html", u"<!doctype html><title></title>"),

    (u"xhtml", u'<html xmlns="http://www.w3.org/1999/xhtml"></html>'),
    (u"svg", u'<svg xmlns="http://www.w3.org/2000/svg"></svg>'),
    (u"mathml", u'<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>'),

    (u"bare_xhtml", u"<html></html>"),
    (u"bare_svg", u"<svg></svg>"),
    (u"bare_mathml", u"<math></math>"),

    (u"xhtml_ns_removed", u"""\
<html xmlns="http://www.w3.org/1999/xhtml">
  <head><script>
    var newRoot = document.createElementNS(null, "html");
    document.removeChild(document.documentElement);
    document.appendChild(newRoot);
  </script></head>
</html>
"""),
    (u"xhtml_ns_changed", u"""\
<html xmlns="http://www.w3.org/1999/xhtml">
  <head><script>
    var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc");
    document.removeChild(document.documentElement);
    document.appendChild(newRoot);
  </script></head>
</html>
"""),
)

EXTENSIONS = (
    u"html",
    u"xhtml",
    u"xml",
    u"svg",
    # Was not able to get server MIME type working properly :(
    #"mml",
)

def __main__():
    if len(sys.argv) > 1:
        print(u"No arguments expected, aborting")
        return

    if not os.access(THIS_NAME, os.F_OK):
        print(u"Must be run from the directory of " + THIS_NAME + u", aborting")
        return

    for name in os.listdir(u"."):
        if name == THIS_NAME:
            continue
        os.remove(name)

    manifest = open(u"MANIFEST", u"w")

    for name, contents in FILES:
        for extension in EXTENSIONS:
            f = open(name + u"." + extension, u"w")
            f.write(contents)
            f.close()
            manifest.write(u"support " + name + u"." + extension + u"\n")

    manifest.close()

__main__()