#!/usr/bin/python
from __future__ import print_function
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"
"),
(u"xhtml", u''),
(u"svg", u''),
(u"mathml", u''),
(u"bare_xhtml", u""),
(u"bare_svg", u""),
(u"bare_mathml", u""),
(u"xhtml_ns_removed", u"""\
"""),
(u"xhtml_ns_changed", u"""\
"""),
)
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__()