1 from xml
.dom
import minidom
2 from zeroinstall
.injector
import namespaces
, model
3 from logging
import warn
6 """Find the single release marked as 'testing' and make it 'stable'."""
7 doc
= minidom
.parseString(data
)
9 all_impls
= doc
.documentElement
.getElementsByTagNameNS(namespaces
.XMLNS_IFACE
, 'implementation')
11 if get_stability(x
) == 'testing':
12 testing
.append((get_version(x
), x
))
14 raise Exception('No implementations are currently "testing"!')
16 testing
= sorted(testing
)
17 higest_version
= testing
[-1][0]
18 latest_testing
= [impl
for version
, impl
in testing
if version
== higest_version
]
20 if len(latest_testing
) < len(testing
):
21 warn("Multiple 'testing' versions - changing %d (of %d) with version %s", len(latest_testing
), len(testing
), model
.format_version(higest_version
))
23 for impl
in latest_testing
:
24 impl
.setAttribute('stability', 'stable')
26 return doc
.toxml('utf-8')
29 root
= x
.ownerDocument
.documentElement
31 stab
= x
.getAttribute('stability')
37 root
= x
.ownerDocument
.documentElement
39 version
= x
.getAttribute('version')
41 mod
= x
.getAttribute('version-modifier')
42 if mod
: version
+= mod
43 return model
.parse_version(version
)
45 raise Exception("No version on %s" % x
)