#!/usr/bin/env python
import urllib2, re, glob, shutil

dlpage = urllib2.urlopen("http://www.stack.nl/~dimitri/doxygen/download.html")
version, = re.findall(r'''ftp://ftp\.stack\.nl/pub/users/dimitri/doxygen-([0-9.]+)\.src\.tar\.gz''', dlpage.read())

newBuildFile = "doxygen-" + version + ".build"
buildFile, = glob.glob("doxygen-*.build")

if buildFile != newBuildFile:
    print "mv {old} {new}".format(old=buildFile, new=newBuildFile)
    shutil.move(buildFile, newBuildFile)
