OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 import os |
| 3 import sys |
| 4 |
| 5 THIS_NAME = "generate.py" |
| 6 |
| 7 # Note: these lists must be kept in sync with the lists in |
| 8 # Document-createElement-namespace.html, and this script must be run whenever |
| 9 # the lists are updated. (We could keep the lists in a shared JSON file, but |
| 10 # seems like too much effort.) |
| 11 FILES = ( |
| 12 ("empty", ""), |
| 13 ("minimal_html", "<!doctype html><title></title>"), |
| 14 |
| 15 ("xhtml", '<html xmlns="http://www.w3.org/1999/xhtml"></html>'), |
| 16 ("svg", '<svg xmlns="http://www.w3.org/2000/svg"></svg>'), |
| 17 ("mathml", '<mathml xmlns="http://www.w3.org/1998/Math/MathML"></mathml>'), |
| 18 |
| 19 ("bare_xhtml", "<html></html>"), |
| 20 ("bare_svg", "<svg></svg>"), |
| 21 ("bare_mathml", "<math></math>"), |
| 22 |
| 23 ("xhtml_ns_removed", """\ |
| 24 <html xmlns="http://www.w3.org/1999/xhtml"> |
| 25 <head><script> |
| 26 var newRoot = document.createElementNS(null, "html"); |
| 27 document.removeChild(document.documentElement); |
| 28 document.appendChild(newRoot); |
| 29 </script></head> |
| 30 </html> |
| 31 """), |
| 32 ("xhtml_ns_changed", """\ |
| 33 <html xmlns="http://www.w3.org/1999/xhtml"> |
| 34 <head><script> |
| 35 var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "abc"); |
| 36 document.removeChild(document.documentElement); |
| 37 document.appendChild(newRoot); |
| 38 </script></head> |
| 39 </html> |
| 40 """), |
| 41 ) |
| 42 |
| 43 EXTENSIONS = ( |
| 44 "html", |
| 45 "xhtml", |
| 46 "xml", |
| 47 "svg", |
| 48 # Was not able to get server MIME type working properly :( |
| 49 #"mml", |
| 50 ) |
| 51 |
| 52 def __main__(): |
| 53 if len(sys.argv) > 1: |
| 54 print "No arguments expected, aborting" |
| 55 return |
| 56 |
| 57 if not os.access(THIS_NAME, os.F_OK): |
| 58 print "Must be run from the directory of " + THIS_NAME + ", aborting" |
| 59 return |
| 60 |
| 61 for name in os.listdir("."): |
| 62 if name == THIS_NAME: |
| 63 continue |
| 64 os.remove(name) |
| 65 |
| 66 manifest = open("MANIFEST", "w") |
| 67 |
| 68 for name, contents in FILES: |
| 69 for extension in EXTENSIONS: |
| 70 f = open(name + "." + extension, "w") |
| 71 f.write(contents) |
| 72 f.close() |
| 73 manifest.write("support " + name + "." + extension + "\n") |
| 74 |
| 75 manifest.close() |
| 76 |
| 77 __main__() |
OLD | NEW |