Sure, this is just copied from github.py and modified as little as possible to work with Bitbucket.