5
# deactivate error messages from the validation [libxml2.htmlParseDoc]
9
libxml2.registerErrorHandler(noerr, None)
11
class UnknownBuildID(Exception):
14
VERSIONS = {"STABLE": "https://bugs.launchpad.net/",
15
"EDGE": "https://bugs.edge.launchpad.net/",
16
"STAGING": "https://bugs.staging.launchpad.net/"}
18
re_build_stable = re.compile(r"<!-- Launchpad.*\(r(\d+)\) -->")
19
re_build_edge = re.compile(r"\(r(\d+)\)")
21
def get_build_id(url):
23
content = urllib.urlopen(url).read()
24
ctx = libxml2.htmlParseDoc(content, "UTF-8")
29
x = ctx.xpathEval('//span[@id="lp-version"]')
30
build = int(re_build_edge.search(x[0].content).group(1))
33
# STABLE: version number is no longer shown on the page itself
34
# but as a comment in the source
35
build = int(re_build_stable.search(content).group(1))
41
if __name__ == '__main__':
42
for k, i in VERSIONS.iteritems():
43
print k, get_build_id(i)