Added --set-interface-uri to set the main URI.
[0publish.git] / stable.py
blob408ae760d099fa03d6aae6d4f7bb9168e0833307
1 from xml.dom import minidom
2 from zeroinstall.injector import namespaces, model
4 def mark_stable(data):
5 """Find the single release marked as 'testing' and make it 'stable'."""
6 doc = minidom.parseString(data)
7 testing = []
8 all_impls = doc.documentElement.getElementsByTagNameNS(namespaces.XMLNS_IFACE, 'implementation')
9 for x in all_impls:
10 if get_stability(x) == 'testing':
11 testing.append(x)
12 if len(testing) == 0:
13 raise Exception('No implementations are currently "testing"!')
14 if len(testing) > 1:
15 raise Exception("Multiple 'testing' implementations!")
17 testing[0].setAttribute('stability', 'stable')
19 return doc.toxml()
21 def get_stability(x):
22 root = x.ownerDocument.documentElement
23 while x is not root:
24 stab = x.getAttribute('stability')
25 if stab: return stab
26 x = x.parentNode
27 return 'testing'