1 from xml
.dom
import minidom
2 from zeroinstall
.injector
import namespaces
5 doc
= minidom
.parseString(data
)
8 for archive
in doc
.documentElement
.getElementsByTagNameNS(namespaces
.XMLNS_IFACE
, 'archive'):
9 href
= archive
.getAttribute('href')
10 type = archive
.getAttribute('type')
13 if href
.endswith('.tar.bz2'):
14 type = "application/x-bzip-compressed-tar"
15 elif href
.endswith('.tgz') or href
.endswith('.tar.gz'):
16 type = "application/x-compressed-tar"
18 raise Exception("Can't guess type for " + href
)
19 archive
.setAttribute('type', type)