Remove any version-modifier attribute when releasing. The idea is that you put '...
[0publish.git] / stable.py
blob2996edc89edda252013567e5c2aec34f5d37a849
1 from xml.dom import minidom
2 from zeroinstall.injector import namespaces, model
3 from logging import warn
5 def mark_stable(data):
6 """Find the single release marked as 'testing' and make it 'stable'."""
7 doc = minidom.parseString(data)
8 testing = []
9 all_impls = doc.documentElement.getElementsByTagNameNS(namespaces.XMLNS_IFACE, 'implementation')
10 for x in all_impls:
11 if get_stability(x) == 'testing':
12 testing.append(x)
13 if len(testing) == 0:
14 raise Exception('No implementations are currently "testing"!')
15 impl = testing[-1]
16 if len(testing) > 1:
17 warn("Multiple 'testing' implementations - changing last one (%s)", impl.getAttribute('version'))
19 impl.setAttribute('stability', 'stable')
21 return doc.toxml()
23 def get_stability(x):
24 root = x.ownerDocument.documentElement
25 while x is not root:
26 stab = x.getAttribute('stability')
27 if stab: return stab
28 x = x.parentNode
29 return 'testing'