Remove temporary files after signing.
[0publish.git] / create.py
bloba8f2a72d22d41b814ef58f73cc19d710297abf0c
1 import os
2 from xml.dom import minidom, XMLNS_NAMESPACE
3 from zeroinstall.injector.namespaces import XMLNS_IFACE
5 def create(f):
6 assert not os.path.exists(f)
7 name = os.path.basename(f)
9 impl = minidom.getDOMImplementation()
10 doc = impl.createDocument(XMLNS_IFACE, 'interface', None)
12 def text(name, value):
13 e = doc.createElementNS(XMLNS_IFACE, name)
14 e.appendChild(doc.createTextNode(value))
15 return e
17 root = doc.documentElement
18 root.setAttributeNS(XMLNS_NAMESPACE, 'xmlns', XMLNS_IFACE)
19 root.setAttribute('uri', "http://SITE/interfaces/%s" % name)
21 root.appendChild(doc.createComment(
22 " Set the uri attribute above to a location from which\n"
23 " this file can be downloaded. Try to choose a\n"
24 " location that won't change! "))
26 root.appendChild(text("name", name))
27 root.appendChild(text("summary", 'a brief one-line summary'))
28 root.appendChild(text("description",
29 "A longer, multi-line description of the behaviour of the\n"
30 "program goes here. State clearly what the program is for\n"
31 "(clearly enough that people who don't want it will\n"
32 "realise too)."))
34 group = doc.createElementNS(XMLNS_IFACE, 'group')
35 root.appendChild(group)
37 group.appendChild(doc.createComment(
38 ' Add dependencies and implementations here. '))
40 doc.writexml(file(f, 'w'), addindent = " ", newl = '\n')
42 print "Wrote '%s'." % f
43 print "Now edit it in a text editor, and set the uri, summary "
44 print "and description as indicated. When you're ready to add an "
45 print "implementation, run 0publish on the file again."