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

dlpage = urllib2.urlopen("http://www.scons.org/")
versions = re.findall(r'''http://sourceforge.net/projects/scons/files/scons/([0-9.]+)''', dlpage.read())

versions.sort(key=lambda x: map(int, x.split(".")) )
version = versions[-1]

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

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