Validate interface before saving.
[0publish.git] / create.py
blob0d002c2c2d26263c2d117901744e75f640c5f8ed
1 import os
2 from xml.dom import minidom, XMLNS_NAMESPACE
3 from zeroinstall.injector.namespaces import XMLNS_IFACE
6 _template = """<?xml version="1.0" ?>
7 <?xml-stylesheet type='text/xsl'
8 href='http://0install.net/2006/stylesheets/interface.xsl'?>
10 <interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
11 <name>%s</name>
12 <summary>cures all ills</summary>
13 <description>
14 A longer, multi-line description of the behaviour of the
15 program goes here. State clearly what the program is for
16 (clearly enough that people who don't want it will
17 realise too).
19 Use a blank line to separate paragraphs.
20 </description>
22 <!-- Optionally, uncomment this to specify an icon: -->
23 <!-- <icon href='http://site/icon.png' type='image/png'/> -->
25 <!-- Optionally, uncomment this to give the address of
26 the signed master interface: -->
27 <!-- <feed-for interface='http://site/interface'> -->
29 <!-- Set 'main' to the relative path of your default
30 executable within the implementation's directory.
31 E.g.: "myprog" or "bin/myprog" -->
32 <group main='myprog'>
33 <!-- List any libraries your program needs here -->
34 <!--
35 <requires interface="http://site/library">
36 <environment insert="python" name="PYTHONPATH"/>
37 </requires>
38 -->
40 <!-- List all implementations here.
41 For local interfaces, '.' is a relative path from this
42 interface file to the directory containing the program.
43 Usually, you can just leave it as '.'.
44 -->
45 <implementation id="." version="0.1" released='Snapshot'/>
46 </group>
47 </interface>
48 """
50 def create(f):
51 assert not os.path.exists(f)
52 name = os.path.basename(f)
53 return _template % (name.split('.', 1)[0])